Shortest path algorithms Flashcards

(21 cards)

1
Q

What is the goal of shortest path algorithms?

A

To find the minimum total weight path between nodes in a weighted graph.

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

What data structure is commonly used to implement sparse graphs?

A

An adjacency list.

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

What data structure is good for dense graphs or fast edge lookups?

A

An adjacency matrix.

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

What assumption does Dijkstra’s algorithm require?

A

All edge weights must be non-negative.

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

What does d(u) represent in Dijkstra’s algorithm?

A

The current best-known estimate of the shortest path from source to u.

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

What is δ(u) in Dijkstra’s algorithm?

A

The true shortest distance from the source node to u.

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

What is the invariant in Dijkstra’s algorithm?

A

When a node is added to the settled set S, d(u) = δ(u).

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

What does edge relaxation mean in Dijkstra’s algorithm?

A

Updating d(v) if a better path to v is found through u.

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

How does Dijkstra’s algorithm select the next node to process?

A

It selects the node in the priority queue with the smallest d(u).

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

How do you reconstruct a path in Dijkstra’s algorithm?

A

Keep track of which node each one came from during relaxation, then trace backward.

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 with a heap?

A

Θ((|V| + |E|) log |V|)

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

What is the time complexity of Dijkstra with linear search?

A

Θ(|E| + |V|²)

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

Can Dijkstra’s algorithm handle negative edge weights?

A

No — it assumes all weights are non-negative.

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

What does the Floyd-Warshall algorithm compute?

A

The shortest paths between all pairs of vertices.

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

What principle does the Floyd-Warshall algorithm use?

A

Dynamic programming and the principle of optimality.

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

What is the recurrence used in Floyd-Warshall?

A

δ(i, j, k) = min(δ(i, j, k-1), δ(i, k, k-1) + δ(k, j, k-1))

17
Q

What is the time complexity of Floyd-Warshall?

A

Θ(n³), where n is the number of vertices.

18
Q

Is Floyd-Warshall suitable for negative edge weights?

A

Yes, as long as there are no negative cycles.

19
Q

How does dynamic programming differ from divide and conquer?

A

Dynamic programming solves overlapping subproblems with memoization; divide and conquer splits into disjoint problems.

20
Q

Name one real-world application of Dijkstra’s algorithm.

A

GPS routing or shortest path planning in maps.

21
Q

What is matrix exponentiation useful for in graph theory?

A

Counting paths of fixed lengths (e.g., A² gives number of 2-step paths).