2014-02-26 61 views
-1

我是新来的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? 

在此先感谢

+4

你是如何实现平衡二叉搜索树而不能回答这些问题? – Cameron

回答

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