Core Patterns
Trees & graph traversal
Lesson 5 of 5
Breadth-first versus depth-first traversal, how to represent a graph, and when each search fits.
What you'll learn
- Represent a graph as an adjacency list and reason about its cost
- Choose breadth-first for shortest hops and depth-first for full exploration
- Track visited nodes to avoid cycles and wasted work
Members only
A free account unlocks this lesson and every other one.
Runnable challenges, knowledge checks, and progress that syncs across your devices. No card needed.
Not sure yet? Try the free lesson first: Big-O & complexity