Dijkstra’s Algorithm for Single Source Shortest Paths with Nonnegative Edge Weights Flashcards

1
Q

What is the main purpose of Dijkstra’s Algorithm?

A

To find the shortest path from a source node to all other nodes in a graph with non-negative edge weights.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
2
Q

What type of graph can Dijkstra’s Algorithm be applied to?

A

Graphs with non-negative edge weights, possibly with cycles, but no negative weights.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
3
Q

What type of algorithm is Dijkstra’s?

A

It is a greedy algorithm.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
4
Q

What key data structure is used in Dijkstra’s Algorithm?

A

Min-priority queue (heap) keyed by distance estimates (d-values).

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
5
Q

What is the relaxation condition in Dijkstra’s Algorithm?

A

If u.d + w(u,v) < v.d, then update v.d = u.d + w(u,v) and v.π = u.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
6
Q

What is the initialization step in Dijkstra’s Algorithm?

A

Set source.d = 0 and all other vertex.d = ∞, vertex.π = NIL.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
7
Q

How does the main loop of Dijkstra’s Algorithm operate?

A

Extract the node with smallest d-value from heap, then relax all its outgoing edges.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
8
Q

What does ‘extract_min’ do in the priority queue?

A

It removes and returns the vertex with the smallest distance estimate.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
9
Q

Why do we call Dijkstra’s Algorithm greedy?

A

Because it always selects the node with the current smallest d-value.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
10
Q

How many times is each edge relaxed in Dijkstra’s Algorithm?

A

Exactly once.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
11
Q

What is the time complexity of Dijkstra’s Algorithm using a min-heap?

A

O((m + n) log n), where n is the number of vertices and m is the number of edges.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
12
Q

Why is Dijkstra’s Algorithm faster than Bellman-Ford?

A

Because each edge is relaxed once and it uses a priority queue for efficient node selection.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
13
Q

Can Dijkstra’s Algorithm handle negative weight edges?

A

No, it only works with non-negative weights.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
14
Q

What happens when a node’s d-value is updated?

A

It must be bubbled up in the heap using decrease_key.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
15
Q

What is stored in each vertex during the algorithm?

A

Its current distance estimate (d) and its parent node (π).

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
16
Q

What is the main goal of the proof of Dijkstra’s Algorithm?

A

To show that Dijkstra’s Algorithm correctly computes shortest paths from a source node to all other nodes.

17
Q

What is the key invariant in Dijkstra’s Algorithm?

A

For every vertex v in the processed set P, v.d equals the shortest path distance from source s to v.

18
Q

What is set P in the context of Dijkstra’s Algorithm?

A

P is the set of vertices that have been removed from the priority queue and fully processed.

19
Q

What does the proof use to establish correctness?

A

Mathematical induction on the number of times the main loop executes.

20
Q

What is the base case for the induction proof?

A

When the source node s is first chosen, s.d = 0 = δ(s, s), so the invariant holds.

21
Q

What is assumed in the inductive hypothesis?

A

That for all vertices in P, v.d = δ(s, v).

22
Q

What must be proven in the inductive step?

A

That for the next chosen node u (with smallest d in V-P), u.d = δ(s, u).

23
Q

Why is u.π always in the processed set P?

A

Because edges are only relaxed from processed vertices, so u’s parent must have been processed.

24
Q

What contradiction does the proof use?

A

It assumes there is a shorter path to u through w ∈ P, but that would imply u.d is not the smallest, contradicting its selection.

25
Why must edge weights be non-negative in Dijkstra’s Algorithm?
Because the proof relies on the fact that extending a path cannot decrease total path cost.
26
What would go wrong if edge weights were negative?
A path through w might have a smaller cost due to negative weights, breaking the correctness invariant.
27
What is the final implication of the proof when the algorithm finishes?
Since all nodes are in P, their d-values are guaranteed to be the true shortest path distances.
28
Why does Dijkstra’s Algorithm never revisit a node?
Because once a node’s shortest path is finalized (added to P), it cannot be improved.
29
How does Dijkstra ensure optimality with only local (greedy) decisions?
Because at each step, it processes the unvisited node with the current smallest distance estimate, which must be correct due to non-negative weights.