Breadth-First Search
LinkedIn "Degrees of Separation" — BFS finds the shortest connection path between two
people
SOCIAL GRAPH
Click two people to connect
Med
BFS explores nodes level by level — all friends first, then
friends-of-friends, and so on. This guarantees the shortest path (fewest hops). LinkedIn
uses this to compute "2nd connection" and "3rd connection" badges on every profile.
Depth-First Search
OS File Search — DFS dives deep into each folder branch before backtracking, just like
your OS "Find File"
FILE SYSTEM
Click any file to search for it
Med
DFS uses a stack (LIFO) — it commits fully to one branch before trying
another. Operating systems use DFS to traverse directory trees when searching files or computing folder
sizes. Web crawlers also use DFS to index deep page hierarchies. Watch how it backtracks
from dead-end folders.
Uniform Cost Search
Flight Routes ↗
Cheapest Flight Finder — UCS always expands the lowest cumulative cost, exactly how
Google Flights routes work
FLIGHT NETWORK
Priority Queue
——
Click source → destination city
Med
UCS uses a min-heap priority queue — always expanding the node with the
lowest total cost so far. It's Dijkstra's algorithm applied to graphs. The priority queue
panel shows live which city is cheapest to reach next. UCS guarantees the optimal (cheapest)
route.
Depth-Limited Search
Game AI — DLS powers Tic-Tac-Toe's minimax AI with a depth-3 cutoff, just like chess
engines limiting lookahead
GAME TREE
Your turn — play X
AI Decision Tree (depth limit = 3)
Waiting for AI to think…
Play a move to see the AI search depth-limited game states and
pick the best response.
DLS is DFS with a hard depth cutoff. The AI uses minimax — exploring
all possible game states up to depth 3, scoring them, and picking the best move. Chess engines like
Stockfish use this same idea (with alpha-beta pruning) but at depths of 20–30. The tree shows moves pruned
when the limit hits.
A* Search
Map Implementation
↗
City Delivery Route — A* uses f=g+h to find the optimal path through weighted terrain,
exactly how GPS navigation works
NAVIGATION
Road
(1)
Traffic
(3)
Construction
(5)
Building
Click Start/End to move them.
Click empty cell for walls.
Med
A* combines actual cost g(n) (distance traveled) and heuristic
h(n) (Manhattan distance to goal) into f(n) = g + h. This makes it smarter
than UCS — it prioritizes nodes closer to the goal. GPS systems, game NPCs, and robotics all use A* for its
speed and optimality guarantee.
Greedy Best-First
Why Greedy Fails — on the same maze, Greedy takes the "locally best" path and gets
trapped; A* finds the true optimum
COMPARISON
GREEDY — h(n) only
A* — f(n) = g+h
Click Start/End to move. Click
empty cell for walls.
Med
Greedy uses only h(n) — the straight-line guess to the goal. It's fast
but not optimal. In tricky mazes it charges toward the goal and gets stuck, exploring many dead ends. A*
avoids this by also tracking actual cost. Early GPS units used greedy-style heuristics — they often gave bad
routes!
Bidirectional BFS
WhatsApp Message Routing — two BFS frontiers expand simultaneously from sender and
receiver until they meet
NETWORK
Forward frontier (sender)
Backward frontier (receiver)
Meeting point
Click any two nodes to change
Sender/Receiver
Med
Bidirectional BFS runs two simultaneous searches — one from the source forward, one from
the destination backward. They meet in the middle. This can reduce nodes explored from b^d to
2×b^(d/2) — exponentially fewer! Network routing protocols like OSPF use this principle to find
paths faster in large graphs.