DSA
intermediate
Binary Search Tree (BST)
A hierarchical data structure where each node has at most two children. For any node, the left child is smaller and the right child is larger, allowing for efficient O(log n) average-case search, insertion, and deletion (this degrades to O(n) on an unbalanced tree).
Binary Search Tree
O(h) ops
Ready
Binary Search Tree Structure
Ready to perform BST operations
Normal
Visiting
New
Found
Height
0
Nodes
0
Operation
complete
Path Length
0
In-order traversal
Sequence
Keys 50, 30, 70, 20, 40 were inserted into an empty BST. Order the keys as an in-order traversal visits them.
Tap a piece, then tap where it goes — or drag it. Tap the tray to take one back.
- 1Drop a step here
- 2Drop a step here
- 3Drop a step here
- 4Drop a step here
- 5Drop a step here
5 pieces left to place
Test your knowledge
20 questions
Question 1 of 20
Score: 0
What is the worst-case time complexity of searching in a BST?
When to reach for this
- When you need to maintain a **Sorted** collection
- When you need fast Lookup, Insert, and Delete (O(log n))
- Finding the closest value, floor, or ceiling
Interview Questions
Facebook
Amazon
Bloomberg
Microsoft
Apple
Amazon
Google
Google
Airbnb
Microsoft
Love this visualization?
Sign up to track your progress, earn achievements, use the AI assistant, and access your personal learning dashboard.
100% free • No credit card required