12 Shortest Path Flashcards

1
Q

Shortest Path Problem

A

Needs weighted graph that can be directed or undirected.

Weights can be:
1. Uniform
2. Non-Negative, Negative, Zero, or Positive.

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

Single-source shortest paths problem:

A

Find a shortest path from a source (start) vertex ‘s’ to every other vertex ‘v’

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

Single-pair shortest path problem:

A

Find a shortest path for a source (start) vertex ‘s’ to a goal vertex ‘g’.

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

All pairs shortest-path problem:

A

Find a shortest path between all pairs of vertices.

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

Breadth-First Search

A

Discovers all vertices at distance k from s before discovering any vertices at distance k+1.

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

Total Running Time of BFS

A

O(V+E)

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

If the graph is unweighted (or has uniform weights), the breadth-first tree is also:

A

A shortest path tree

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

Dijkstra’s Algorithm

A

Solves the single-source shortest path problem in a weighted graph where all the weights are non-negative

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

Total Time of Dijkstra’s Algorithm If Priority Queue is Vector

A

O(V^2 + E) = O(V^2)

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

Total Time of Dijkstra’s Algorithm If Priority Queue is Binary Heap

A

O(V + E log V)

Connected Graph: O(E log V) since V = O(E)
Sparse graph: O(V log V) since E = O(V)

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

Single Pair vs Single Source

A

Pair is solved more efficiently (on average) but its complexity analysis is somewhat different.

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