The GATE Grind

GATE 2013 CS (CS1) – Question 17

Programming and Data Structures · Trees and Binary Search Trees · 1 mark · Multiple choice

What is the tightest worst-case upper bound for inserting into a binary search tree with n nodes?

  1. $O(1)$
  2. $O(\log n)$
  3. $O(n)$
  4. $O(n\log n)$

Practise this question in The GATE Grind →

Show answer and explanation

Correct answer: (C) $O(n)$

Explanation

An unrestricted BST may be a chain of n nodes. Inserting a key beyond its end traverses the entire chain, taking linear time. Since at most n existing nodes are visited, the tight bound is O(n), C. A logarithmic guarantee requires balancing.

More Trees and Binary Search Trees questions

All Trees and Binary Search Trees questions →