Foundations
Linear Structures
Hashing
Array and String Patterns
Recursion, Search, and Sorting
Problem Solving Patterns
Algorithm Searching
Sorting Algorithms
Array Algorithms
Grid Algorithms
Linear Structure Algorithms
Hashing Algorithms
Recursion and Backtracking
Greedy Algorithms
Tree and Heap Algorithms
Graph Algorithms
Dynamic Programming Algorithms
String Algorithms
Math Algorithms
Keyboard ready
Space plays. Arrow keys step. R restarts.
LAB Binary Search Trees Lab
Trees
Concept shape
Core
Definition
A BST keeps smaller values on the left and larger values on the right.
Step 1 / 5
Concept shape
Trees Core
Binary Search Trees
Welcome to the Binary Search Trees concept lab. A BST keeps smaller values on the left and larger values on the right. The must know points are: Inorder traversal gives sorted values. Balanced height gives O(log n) search. Unbalanced trees can degrade to O(n). The common operations are: search O(h), insert O(h), delete O(h). The complexity shape is O(h), balanced O(log n), worst O(n). Watch out for these pitfalls: Ignoring duplicates policy. Assuming a tree is balanced automatically. Related algorithms include BST Search, Tree Traversal.
Concept details
A BST keeps smaller values on the left and larger values on the right.
Must know
- Inorder traversal gives sorted values.
- Balanced height gives O(log n) search.
- Unbalanced trees can degrade to O(n).
Complexity
O(h), balanced O(log n), worst O(n)
1.0x