平衡二进制搜索树问题

时间:2014-02-26 19:32:30

标签: c++ binary-search-tree

我是c +的新手,我刚刚创建了一个平衡的二叉搜索树 有几个问题。

1) What is the efficiency of inserting/looking up/ removing/ from an ideally balanced binary tree is big-O of?
2) How would I order A.go left, B. go right, C visit in pre-order, in-order and post-order traversal?
3) Last question is infinite recursion is one cause of an infinite loop?

提前致谢

1 个答案:

答案 0 :(得分:3)

1) The efficiency of inserting/looking up/ removing is  O(log2(n)) 
if you didn't understand that I would recommend googling it
2) Pre-Order : Visit, go left and visit until leaf is reached, then go up and right & visit. Then repeat going left and visiting.
   In order : Go to the left most child and visit, then go up and visit, then go right and visit. repeat from start.
   Post- Order: A (visit last) A->B->C
3) And recursion isn't a loop. 
I would recommend googling all these questions/ wiki has good information about binary     search tree