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 nodes?
View worked solution
Answer: C
To find the tightest upper bound for inserting an object into a Binary Search Tree (BST) of nodes, we must consider the worst-case scenario.
In a Binary Search Tree, the insertion operation involves traversing from the root down to a leaf position where the new node can be placed. The time complexity of this operation is proportional to the height of the tree, :
Depending on the structure of the BST, the height varies:
- Best/Average Case (Balanced Tree): The height of the tree is , leading to an insertion time of .
- Worst Case (Skewed Tree): If the elements are inserted in sorted order (e.g., ), the tree degenerates into a linear chain (a skewed tree). In this case, the height of the tree is .
Since the question asks for the upper bound (which must cover the worst-case scenario) for a standard, un-balanced BST, the tightest upper bound is .
Free practice · Your answers on this page are not saved.
