Shortest Path & Dijkstra's Algorithm Flashcards
(7 cards)
What is the goal of Shortest path algorithms ?
Find the most efficient route through a graph based on edge weights.
What are the variations of shortest path algorithms ?
Single-Source Shortest Path (SSSP): From one node to all others,
Single-Destination Shortest Path (SDSP): from all nodes to one,
All-Pairs Shortest Path (APSP): BEtween every pair of nodes.
What is Dijkstra’s Algorithm ?
SSSP algorithm with non-negative weights,
Greedy approach: always picks the node with the shortest know distance,
D array - Distance estimates from the start node,
T array - Tracks which nodes are tight (final shortest distance known)
P array - Records predecessors to reconstruct the actual path.
Array based: O(V^2)
Binary heap: O((V+E) log V)
When is Dijkstra’s Algorithm used ?
GPS/Navigation,
Network Routing,
Game AI pathing,
Robotics motion planning.
What is a Minimal Spanning Tree (MST) ?
A subtree of the edges of a graph that connects all nodes within the graph.
What is Prim’s Algorithm ?
Starts from a vertex, grows MST by adding the smallest-weight edge from inside the tree,
Best for dense graphs,
Time Complexity: O(|E| + |V| log |V|) with Fibonacci heap.
What is Kruskal’s Algorithm ?
Starts with edges; adds the smallest edge that doesnt’t form a cycle using disjoint-set structure,
Best for sparse graphs,
Time Complexity: O(|E| log |V|).