二叉搜索树就地转双向链表二叉搜索树头文件C++

来源:互联网 发布:java 高并发 唯一主键 编辑:程序博客网 时间:2024/06/03 19:28
 
//binarySearchTree.h -- 2011-07-27-17.14class binarySearchTree{public:enum direction {Direction_Left, Direction_Right} ;typedef int Item ;typedef struct node{Item item ;struct node * left, * right ;} Node ;private:Node * m_root ;int m_current ;Node * m_makeNode (const Item item) ;void m_print (const Node & node) ;Node * m_leftmostOrRightmostNode (Node * const pNode, const direction directionComeFrom) ;void m_removeAll (Node * pNode) ;public:binarySearchTree (void) ;bool isEmpty (void) ;bool insert (const Item item) ;bool remove (const Item item) ;void print (void) ;//If you called becomeToATwoWayCirculationLinkedListAndPrintItAndEmptyTheTree()//will change the tree to a two way circulation linked list and print all the elements in diminsihing order and increment order,//and empty the tree at last.void becomeToATwoWayCirculationLinkedListAndPrintItAndEmptyTheTree (const direction headDirection) ;~binarySearchTree (void) ;} ;