Question
The worst case running time to search for an element in a balanced binary search tree with elements is
Official answer and solution
- Official answer
- C
- From
- Official GATE 2012 answer key
Solution
Calculate the worst-case search time in a balanced binary search tree with N elements as Theta(log N).
In a balanced binary search tree (such as an AVL tree or Red-Black tree) containing elements, the height of the tree is bounded by . Consequently, searching for an element takes worst-case time proportional to its height:
Here, the number of elements is given as :
As , the linear term dominates the logarithmic term :
Therefore, the worst-case running time to search for an element is , corresponding to option (C).
C
The answer is the one in the official GATE answer key. The solution is this site's own explanation.
Source
- Paper
- GATE 2012 Computer Science and Information Technology (CS)
- Question
- 5 of 65, printed as CS Q.5
- Section
- Computer Science and Information Technology
Report an error in this question
GATE questions are the work of the organising institutes. This site is independent and is not affiliated with them.