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 BFS Concept Lab
Graphs
Concept shape
Practice pattern
Definition
Breadth-first search explores nodes by distance from the start using a queue.
Step 1 / 5
Concept shape
Graphs Practice pattern
BFS Concept
Welcome to the BFS Concept concept lab. Breadth-first search explores nodes by distance from the start using a queue. The must know points are: Queue controls level order. Finds shortest path in unweighted graphs. Mark nodes when enqueueing. The common operations are: enqueue, dequeue, visit neighbors. The complexity shape is O(V + E). Watch out for these pitfalls: Marking visited too late. Using DFS when shortest unweighted path is needed. Related algorithms include BFS, Level Order Traversal.
Concept details
Breadth-first search explores nodes by distance from the start using a queue.
Must know
- Queue controls level order.
- Finds shortest path in unweighted graphs.
- Mark nodes when enqueueing.
Complexity
O(V + E)
1.0x