Week 10 Flashcards

1
Q

What is topological order?

A

Is a linear ordering of vertices such that vertex a precedes vertex b whenever a directed edge e exists from a to b.

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

When can a topological order be applied?

A

Can only be applied to directed acyclic graphs (DAG)
If cycles exist, no linear ordering is possible.

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

What are some applications of topological order?

A

Taking a sequence of courses given certain course prerequisites.

Scheduling tasks given precedence contraints.

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

Topological Order

What is a sink/minimal vertex?

A

A sink of minimal vertex is a vertex with no outgoing edges.

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

What is the basic idea behind a topological sort?

A

For i to |V|
* find a sink vertex v;
* num(v) = i;
* remove v and all its incident edges

Or in plain english
* Traverse to first sink
* Output sink
* Remove sink
* Repeat

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

Topological sort can be implemented using a variant of the recursive depth first traversal. What is its complexity?

A

Θ (|𝑉| + |𝐸|)

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

When doing topolgical sort, there are two main approaches. What does it mean for us to do an indegree?

A

This alternate approach has us starting at the root. Start with the node that has 0 in degree.

This requires a queue.

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

What is Dijksra’s Algorithm? (Explain generally)

A

Finds the shortest weighted paths from a single source vertex to all other vertices in a weighted, directed or undirected graph.
* All weights must be non-negative
* Must be a simple graph

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

When using Dijkstra’s Algorihmn, what we do need to keep track of and how can it be implemented?

A

For each vertex v, we must keep track of
* whether the vertex still needs to be processed:
* The current distance from the source for the shortest path found so far
* The predecessor vertext for the shortest path found so far.

It can be implemented
* By adding fields to a vertex class
* with parallel arrays (or a table)

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

What is the complexity of Dijkstra’s Algorithm?

A

The complexity is 𝑂( |𝑉|^2 ) ordered squared.

The worst case is when we have a complete graph.

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

What would be the complexity of Dijkstra’s algorithm if we apply it to every vertex as a source?

A

O(|V|^3)

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

What would we do in the case that we want to do a Dijkstra’s Algorithm but using negative weights?

A

In this case we would use Bellman-Ford’s algorithm.

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