What is the time complexity of inserting into a balanced BST?
What is the time complexity of inserting into a balanced BST?
Approach: Analyze traversal to find insertion point.
O(log n). Finding the correct position and performing necessary rotations both take logarithmic time.
Follow-up: What is the complexity of inserting into a simple linked list?
Key concepts: logarithmic time.