🧮Breadth-First Search (BFS)
Also known as BFS, Breadth First Search, Level-Order Traversal
Walking a graph one layer at a time, nearest nodes first.
Think of it like
Think of it like ripples in a pond. They spread out one ring at a time.
Example
Emma's app finds how many steps away Jack is in her friend graph. BFS checks her friends, then theirs, and finds him at step 2.
Why it matters
It is the standard way to find the shortest path when every step costs the same.
Definition
Common mistake
Key takeaways
- 1Layer by layer. Nearest first.
- 2Uses a queue. First in, first out.
- 3Fewest steps. Found first.