StreakPeaked· Practice

ExamsGATETechnical

Which one of the following is the tightest upper bound that represents the time complexity of inserting an object into a binary search tree of n nodes?

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

Correct answer: O(n)

Solution

The time complexity for inserting an object into a binary search tree can be O(n) in the worst case, which occurs when the tree is unbalanced and resembles a linked list, requiring traversal of all n nodes.

Related GATE Technical questions

⚔️ Practice GATE Technical free + battle 1v1 →