现在的位置: 首页 > 综合 > 正文

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

2013年10月05日 ⁄ 综合 ⁄ 共 829字 ⁄ 字号 评论关闭
 
//	binarySearchTree.h -- 2011-07-27-17.14
class 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) ;
} ;

抱歉!评论已关闭.