Skip to content
All tags

#graph-algorithms

3 posts

Stanford CS161 Lecture 9: Graph Representations, DFS, BFS, and Proofs About Search Order

DFS and BFS both scan an adjacency-list graph in O(n+m); DFS finish times produce a topological order for a DAG, while BFS layers equal exact unweighted shortest-path distances.

Stanford CS161 Lecture 10: Why Two DFS Passes Find Strongly Connected Components

Contracting each SCC always produces a DAG; first-pass DFS finish times order those components, and a second pass on the transposed orientation discovers exactly one SCC per DFS tree in O(n+m).

Stanford CS161 Lecture 11: Dijkstra, Bellman-Ford, and Two Orders of Relaxation

Dijkstra finalizes the minimum estimate and relies on nonnegative weights; Bellman-Ford repeatedly relaxes every edge, spending O(nm) to support negative edges and detect a negative cycle reachable from the source.