Balanced BST Implementation
Problem Statement
Design and implement a Balanced Binary Search Tree data structure that supports:
You may implement any self-balancing variant (e.g., AVL Tree or Red-Black Tree).
✅ Functional Requirements
Insert(key)
Delete(key)
Search(key)
Traversal Methods
Balance Check
⚙️ Non-Functional Requirements
Aspect with Description
Time Complexity
All major operations (insert, delete, search) should be O(log n)
Space Complexity
Should use O(n) space for tree storage
Scalability
Should handle large numbers of insertions efficiently
Extensibility
Should allow adding additional features (e.g., range queries, min/max lookup)
Correctness
Tree must maintain BST ordering and balancing properties after each operation
🧱 Key Classes / Interfaces
💡 Example Scenario -------------------------
1
2Input: Insert keys [10, 20, 30, 40, 50, 25]
3Output: Tree is balanced after each insertion (as per AVL rotation rules)
4
5Inorder Traversal after all insertions: [10, 20, 25, 30, 40, 50]
6Search(25): Found
7Delete(40): Tree rebalanced💬 Discussion Points (for Interview)
🧠 Design Hints
If implementing an AVL Tree:
🧾 Final Interview Prompt
Design and implement a Balanced Binary Search Tree (BST) supporting insertion, deletion, search, and traversal operations.
Ensure that the tree automatically rebalances after every insertion or deletion to maintain O(log n) performance.
Discuss how you detect and correct imbalance and which balancing approach (AVL or Red-Black) you used.