实现Avl平衡树 一.介绍 AVL树是一种自平衡的二叉搜索树,它由Adelson-Velskii和 Landis于1962年发表在论文<An algorithm for the organization of information>中.AVL树的特点是,其左右子树的高度差的绝对值小于2(空树的高度定义为 -1,无子树的树高度为0).如下图所示,左边的二叉树为AVL树,而右边的二叉树root节点的左子树高度为2,右子树高度为0,高度差为2,不是AVL树.与普通二叉树相同的是查找和遍历:但是
C++实现的avl平衡树 #include <stdlib.h> #include <time.h> #include <string.h> #include <vector> #include <stdio.h> using namespace std; class AvlNode { public : int data; AvlNode *parent; AvlNode *left; AvlNode *right; int height; i