Cheat sheets

ALG-21Cheat sheet1 pageIn a paid pack

Dijkstra and Bellman-Ford

Relaxation and predecessor pointers; Dijkstra's algorithm traced vertex by vertex on a five-vertex graph with the distance table after each extraction and the shortest-path tree drawn, its cost with an array, binary heap and Fibonacci heap, and a small graph where one negative edge makes it wrong; Bellman-Ford with V - 1 rounds traced under a fixed edge order, early stopping, negative-cycle detection and its dynamic programming recurrence; what shortest paths mean when a negative cycle is reachable.

Diagrams from ALG-21

ALG-22Cheat sheet1 pageIn a paid pack

DAG Paths, Floyd-Warshall, Complexity Table

Shortest and longest paths in a DAG by relaxing in topological order, traced with a negative edge; Floyd-Warshall's recurrence, the matrices after every intermediate vertex for a four-vertex graph with a negative edge, in-place updates, negative-cycle detection on the diagonal and path recovery; Warshall's transitive closure; BFS for unweighted graphs; a complexity table of every shortest-path method by representation and data structure; a decision flow for choosing one; weight changes and their effect.