Back to Academy
trees
Binary Search Tree
A Binary Search Tree (BST) is a node-based binary tree where each node has at most two children. For each node, all values in the left subtree are less than the node's value, and all values in the right subtree are greater. This property enables efficient searching, insertion, and deletion.
Use Cases
- •Implementing sorted sets and maps
- •Database indexing
- •Priority queues and scheduling
Complexity Analysis
| Metric | Best | Average | Worst |
|---|---|---|---|
| Time | O(log n) | O(log n) | O(n) |
| Space | O(n) | ||
Visualization
Implementation
Output
Click "Run Code" to see output...