GR1: Strongly Connected Components Flashcards

1
Q

Runtime of DFS

A

O(|V| + |E|)

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

Runtime of BFS

A

O(|V| + |E|)

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

Runtime of Topological Sort

A

Just one pass of DFS to get post order numbers (O(|V| + |E|)), then one pass through an array, inserting vertices so they are ordered by post order number (O(|V|)).

O(|V| + |E|) overall.

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

Runtime of SCC

A

Two passes of DFS, so O(|V| + |E|)

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

Runtime of Kruskal’s

A

O(|E| log |V|)

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

Runtime of Dijkstra’s

A

We assume the binary min-heap implementation. Dijkstra uses the BFS framework, which is O(|V| + |E|), but each min-heap operation is O(log |V|), so overall Dijkstra’s is O((|V| + |E|) log |V|).

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

Runtime of Prim’s

A

Prim is nearly identical to Dijkstra except that it uses a different key value for its min-heap. This makes it O((m + n)log n) just like Dijkstra.

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