二叉排序树

头文件

View Code
 1 #ifndef AVLTREE_H
 2 #define AVLTREE_H
 3 
 4 #define SUC 1
 5 #define UNSUC 0
 6 
 7 #include <stdlib.h>
 8 #include <cstdio>
 9 typedef int KeyType;
10 /*还有另一种结构,带指向父节点的指针,编写方法时更简单,但存储耗费更大*/
11  struct AVLNode{
12     struct AVLNode* Lchild;
13     struct AVLNode* Rchild;
14     KeyType m_KType;
15 
16 };
17 
18  typedef struct AVLNode * AVLTree;
19  typedef struct AVLNode * AVLNodePoint;
20 /*插入,删除节点,删除树,遍历,查找*/
21  bool InsertNodeByValue(AVLTree&, KeyType);
22  bool DeleteNodeByValue(AVLTree&,KeyType);
23  bool DeleteTree(AVLTree&);
24  const void TrivalAllTree(AVLTree);
25  const AVLNodePoint ResearchNodeByValue(AVLTree,KeyType);
26 
27  /*二叉排序树(Binary Sort Tree)又称二叉查找树。
28   *它或者是一棵空树;或者是具有下列性质的二叉树:
29   *1)若左子树不空,则左子树上所有结点的值均小于它的根结点的值;
30   *(2)若右子树不空,则右子树上所有结点的值均大于它的根结点的值;
31   *(3)左、右子树也分别为二叉排序树
32   */
33 
34 #endif // AVLTREE_H

 

posted @ 2013-03-15 15:13  WINSTON-DEAN  阅读(40)  评论(0编辑  收藏  举报