in DS edited by
1,134 views
1 vote
1 vote

The height of a binary tree with $n$ nodes, in the worst case is :

  1. $O(log n)$
  2. $O(n)$
  3. $\Omega(n\log n)$
  4. $\Omega(n^2)$
in DS edited by
1.1k views

1 Answer

1 vote
1 vote
In the worst case a binary tree can be either

1. Right Skewed, or

2. Left Skewed.

in either case, the tree is a straight line or TOSET like structure.

Thus making the height equal to the number of nodes in the tree i.e. O(n). Hence, B is the correct option.

Also making the search sequential with O(n) running time.

To mitigate this problem AVL Tree uses the concept of BALANCE FACTOR. Therefore AVL Tree guarantees O(log n) search time.

Related questions