Question

The worst case running time to search for an element in a balanced binary search tree with n2nn 2^n elements is

Choose one option
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 NN elements, the height of the tree is bounded by O(log⁡N)O(\log N). Consequently, searching for an element takes worst-case time proportional to its height:

T(N)=Θ(log⁡N)T(N) = \Theta(\log N)

Here, the number of elements is given as N=n2nN = n 2^n:

log⁡(N)=log⁡(n2n)=log⁡2n+log⁡2(2n)=log⁡2n+n\log(N) = \log(n 2^n) = \log_2 n + \log_2(2^n) = \log_2 n + n

As n→∞n \to \infty, the linear term nn dominates the logarithmic term log⁡2n\log_2 n:

Θ(log⁡2n+n)=Θ(n)\Theta(\log_2 n + n) = \Theta(n)

Therefore, the worst-case running time to search for an element is Θ(n)\Theta(n), corresponding to option (C).

Final answer

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.