All-Pairs Shortest Paths: Floyd-Warshall
Lecture 42 of CS502 Fundamentals of Algorithms presents the Floyd-Warshall algorithm, an exceptionally elegant dynamic programming algorithm that solves the all-pairs shortest paths problem in Theta(|V|^3) time. Instead of bounding paths by the number of edges, Floyd-Warshall considers intermediate vertices on the path. Numbering vertices 1 to n, let d^(k)[i, j] denote the shortest path from vertex i to vertex j whose intermediate vertices are drawn exclusively from the subset {1, 2, ..., k}. When considering vertex k, the algorithm faces a binary choice: either vertex k is not on the shortest path (in which case d^(k)[i, j] = d^(k-1)[i, j]), or vertex k is an intermediate vertex (in which case d^(k)[i, j] = d^(k-1)[i, k] + d^(k-1)[k, j]). The recurrence simplifies to d^(k)[i, j] = min(d^(k-1)[i, j], d^(k-1)[i, k] + d^(k-1)[k, j]). Evaluated via three nested loops over k, i, and j, the algorithm updates a single matrix in-place. The lecture also derives Warshall's algorithm for boolean transitive closure and negative cycle detection. Minimum spanning tree algorithms including Kruskal and Prim formulations are analyzed alongside union-find disjoint set operations. Computational complexity concepts are illustrated through polynomial-time verification, decision reductions, and NP-completeness proofs. By engaging with solved past papers by Moaaz and Waqar Siddhu, learners gain actionable insights into recurrent university exam questions. Interactive quiz assessments on VU SIGMA facilitate rapid knowledge verification and retention of critical algorithmic concepts. Comprehensive coverage of standard academic benchmarks ensures learners communicate with technical precision across computational disciplines. Detailed analysis of recurrence relations highlights the imperative of analyzing base cases and recursive branching factors accurately. Dynamic programming state transitions are contrasted with greedy heuristics to evaluate exactness versus computational overhead. Students evaluate the trade-offs between comparison-based sorting boundaries and specialized linear-time integer distribution sorting techniques. The lesson explores intractable computational problems by examining formal polynomial reductions to known NP-complete cores. Practical code illustrations demonstrate iterative and recursive implementations, memoized table lookups, and pointer-based data structures.
No questions available yet.
There are currently no examination questions published for All-Pairs Shortest Paths: Floyd-Warshall. Explore other curriculum units or build a custom quiz with the practice builder.