Algorithms and Data Structures · Junior · Question 51 of 75
What happens if you insert the values 1, 2, 3, 4, 5 in order into a simple (non-balancing) BST?
- 1The tree balances itself automatically
- 2The insert fails because values must be random
- ✓Correct answer: The tree becomes a chain, and operations degrade to O(n)
Explanation
Each new value is larger than all previous ones and goes to the right, so the tree turns into a linked list. Self-balancing trees (AVL, red-black) rotate nodes to keep the height O(log n).