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 Tree Traversals Lab
Trees
Problem shape
Beginner
8
3
10
1
6
9
14
Core idea
Visit tree nodes in preorder, inorder, postorder, or level order.
Step 1 / 5
Problem shape
Trees Beginner
Tree Traversals
Welcome to the Tree Traversals algorithm lab. Visit tree nodes in preorder, inorder, postorder, or level order. Use it when: Use to inspect, serialize, search, or compute over trees. The time complexity is O(n), and the space complexity is O(h). The pseudocode is: inorder(node) if node is null return inorder(node.left) visit node inorder(node.right) As you practice, track the state that changes and the condition that makes the algorithm stop.
Time
O(n)
Space
O(h)
Pseudocode
inorder(node)
if node is null return
inorder(node.left)
visit node
inorder(node.right) 1.0x