Exams › GATE › Technical
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?
- O(1)
- O(log n)
- O(n)
- 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 →