Learning Experience
Graph Traversal (BFS & DFS)
Two ways to visit every reachable node in a graph — breadth-first spreads outward level by level, depth-first commits to one path and backtracks.
Computer ScienceIntermediate9 min readalgorithmsgraphsbfsdfs
Your learning journey
Every module Axiom offers for graph traversal (bfs & dfs) — work through them in order, or jump to what you need.
TopicLiveUp next
Explains what graphs are, why a queue produces BFS and a stack produces DFS, and when to use each.
VisualizerLive
Animates BFS's expanding frontier searching a maze grid, one queue pop at a time.
QuizLive
Checks that the queue-vs-stack distinction driving BFS vs DFS order is understood.
AI TutorLive
Answers follow-up questions and adapts the explanation to the learner's level.
Cheat SheetLive
One-glance recall of BFS vs DFS, their complexity, and when each applies.
Related concepts
Heaps & Priority Queues
A complete binary tree, stored flat in an array, that keeps the smallest (or largest) element one O(log n) extraction away — the standard way to build a priority queue.
Dijkstra's Algorithm
Find the shortest distance from one start node to every other node in a weighted graph, by always finalizing the nearest unvisited node next and relaxing its edges.