FREE LESSON · Algorithms & data structures · 3 OF 4
Search, Sorting and Graph Traversal Algorithms
Explore without getting lost — Search, sort, and graph traversal patterns
Systematic exploration records what is known and what remains.
Sorting creates order that accelerates later operations. Breadth-first search explores an unweighted graph by distance layers and finds shortest hop counts. Depth-first search follows a path before backtracking, exposing reachability, cycles, and dependency structure. Both require a visited discipline on graphs with cycles.
A frontier stores unfinished work; an invariant explains what removing one item from it means.
Stable sorting preserves a second order
If records are sorted by team and later stably sorted by score, equal-score records retain their previous team order. Stability therefore composes ordering decisions. Whether it matters depends on the product contract, not merely algorithm trivia.
Properties such as stability, online operation, and external-memory behaviour can matter as much as comparison count.