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 BST Search Lab
Trees
Problem shape
Beginner
8
3
10
1
6
9
14
Core idea
Use the binary-search-tree ordering to move left or right from each node.
Step 1 / 5
Problem shape
Trees Beginner
BST Search
Welcome to the BST Search algorithm lab. Use the binary-search-tree ordering to move left or right from each node. Use it when: Use when values are organized in a balanced search tree. The time complexity is O(h), and the space complexity is O(1). The pseudocode is: node = root while node exists if target == node.value return node if target < node.value node = node.left else node = node.right As you practice, track the state that changes and the condition that makes the algorithm stop.
Time
O(h)
Space
O(1)
Pseudocode
node = root
while node exists
if target == node.value return node
if target < node.value node = node.left
else node = node.right 1.0x