Skip to content
Official PYQ · 2012

GATE CS 2012 Q5 — Binary Search Trees

Explain with AI

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

Choose one option
View worked solution

Answer: C

The worst-case running time to search for an element in a balanced binary search tree (BST) with NN elements is proportional to its height, which is Θ(log⁡N)\Theta(\log N).

Given that the number of elements is N=n2nN = n 2^n, we can substitute this into the time complexity expression:

Worst-case search time=Θ(log⁡N)=Θ(log⁡(n2n))\text{Worst-case search time} = \Theta(\log N) = \Theta(\log(n 2^n))

Using the properties of logarithms:

log⁡(n2n)=log⁡n+log⁡(2n)=log⁡n+nlog⁡2\log(n 2^n) = \log n + \log(2^n) = \log n + n \log 2

Assuming the base of the logarithm is 22:

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

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

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

Thus, the worst-case running time is Θ(n)\Theta(n), which corresponds to option C.

Free practice · Your answers on this page are not saved.

Published
Report a correction
Keep exploringMore Binary Search Trees questions