FlashKeepers

Computer Science · College · College and University

Algorithms: Shortest Paths and Spanning Trees

Dijkstra, Bellman-Ford, Floyd-Warshall, Prim, Kruskal, union-find, topological sort and max flow.

About this set

40 basic cards for College Computer Science. Set 5 of 5 in Algorithms. It opens with "What is Dijkstra's algorithm?" and "What is the time complexity of Dijkstra's algorithm with a binary min-heap?". Study it alongside the other College sets below.

40 cards · basic cards · AI-written, checked twice. Edit anything.

Study this set free Look inside first Get FlashKeepers for iPhone

Opens in your browser, no account. Get the iPhone and iPad app · Android app

What is Dijkstra's algorithm?
Show answerA greedy algorithm for finding the shortest path from a source vertex to all other vertices in a weighted graph with non-negative edge weights.
What is the time complexity of Dijkstra's algorithm with a binary min-heap?
Show answerO((V + E) log V), where V is the number of vertices and E is the number of edges.
Why does Dijkstra's algorithm use a greedy strategy?
Show answerIt always selects the unvisited vertex with the smallest known distance, which guarantees the shortest path to that vertex.
Can Dijkstra's algorithm handle negative edge weights?
Show answerNo, it fails with negative weights because the greedy choice of the minimum distance vertex may not lead to the true shortest path.
What is relaxation in Dijkstra's algorithm?
Show answerThe process of updating a vertex's distance if a shorter path is found through another vertex.
What is the Bellman-Ford algorithm?
Show answerAn algorithm that computes shortest paths from a source vertex to all other vertices in a weighted graph, even with negative edge weights.
What is the time complexity of the Bellman-Ford algorithm?
Show answerO(VE), where V is the number of vertices and E is the number of edges.
What is a key advantage of Bellman-Ford over Dijkstra?
Show answerBellman-Ford can handle graphs with negative edge weights.
How does Bellman-Ford detect negative cycles?
Show answerBy running one additional relaxation pass after V - 1 passes; if any distance improves, a negative cycle exists.
How many relaxation passes does Bellman-Ford perform to guarantee shortest paths?
Show answerV - 1 passes, where V is the number of vertices.
What is the Floyd-Warshall algorithm?
Show answerA dynamic programming algorithm that computes the shortest paths between all pairs of vertices in a weighted graph.
What is the time complexity of Floyd-Warshall?
Show answerO(V^3), where V is the number of vertices.
Why is Floyd-Warshall called an all-pairs shortest path algorithm?
Show answerIt computes the shortest distance between every pair of vertices in the graph.
What does the intermediate vertex k represent in Floyd-Warshall's recurrence?
Show answerThe algorithm considers paths from vertex i to vertex j that pass through only vertices 0 to k.
Can Floyd-Warshall detect negative cycles?
Show answerYes, by checking if any diagonal element in the final distance matrix is negative.

25 more cards in the app

Study this set free