1/12
This flashcard set covers SSSP algorithms like Dijkstra's and Bellman-Ford, their various implementation complexities based on data structures (Binary Heap, Sorted/Unsorted Lists), and Minimum Spanning Trees (MST).
Name | Mastery | Learn | Test | Matching | Spaced | Call with Kai | Chat |
|---|
No analytics yet
Send a link to your students to track their progress
Dijkstra's Algorithm
A greedy Single Source Shortest Path (SSSP) algorithm that does not allow negative weights.
Edge Relaxation
A process where if the next edge is smaller, the path is relaxed and replaced with the smaller value to check if it offers a better path.
Dijkstra's Complexity (Adjacency List + Binary Heap)
Building PQ: O(V); Popping all V: O(V×log(V)); Relaxing all E: O(E×log(V)); Total: O((V+E)×log(V)).
Dijkstra's Complexity (Adjacency List + Sorted List)
Building PQ: O(V); Popping all V: O(V) (Total O(V×V), transcript implies V∗); Relaxing all E: O(E) (Total O(E×V), transcript implies E∗); Total: O(EV).
Dijkstra's Complexity (Adjacency List + Unsorted List)
Building PQ: O(V); Popping all V: O(V×V); Relaxing all E: O(E×1); Total: O(V2).
Dijkstra's Complexity (Adjacency Matrix + Binary Heap)
Building PQ: O(V); Popping all V: O(V×log(V)); Relaxing all E: O(V2×log(V)); Total: O(V2×log(V)).
Dijkstra's Complexity (Adjacency Matrix + Sorted List)
Building PQ: O(V); Popping all V: O(V); Relaxing all E: O(V2×V); Total: O(V3).
Dijkstra's Complexity (Adjacency Matrix + Unsorted List)
Building PQ: O(V); Popping all V: O(V×V); Relaxing all E: O(V×V); Total: O(V3).
Bellman Ford
A shortest path algorithm that works with negative weights but cannot be used with negative cycles; it produces up to N−1 passes.
BFS Complexity
O(V+E)
DFS Complexity
O((V+E)×log(V))
Bellman-Ford Complexity
O(V×E)
MST (Minimum Spanning Tree)
A graph objective that is not a shortest path, but aims to minimize the total sum of ALL edges; implemented via the Prim Algorithm.