Exam 2 Flashcards

1
Q

What does V represent?

A

Set of vertices

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

What does E represent?

A

Set of edges

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

What does n = |V| represent?

A

Number of vertices

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

What does m = |E| represent?

A

Number of edges

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

What does s represent?

A

The source vertex

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

What does t represent?

A

The sink vertex

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

What is Breadth-first Search (BFS) algorithm used for?

A

To find unweighted Single Source Shortest Path (SSSP), the distance from s to u if s can reach u, otherwise it is infinity; Runtime is O(n+m)

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

What is Dijkstra’s algorithm used for?

A

To find weighted Single Source Shortest Path (SSSP), the distance from s to u if s can reach u, otherwise it is infinity; Understand that when weights are involved, the runtime increases to O((n+m) log n)

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

What is Depth-first Search (DFS) algorithm used for?

A

It behaves differently for directed and undirected graphs; In a directed graph, the pre/post numbers give information on how a graph COULD be explored; In an undirected graph, the pre/post numbers give information on how a graph WOULD be explored given a starting point; Runtime is O(n+m)

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

What is the Explore algorithm used for?

A

This is a subroutine of DFS and does most of the work in DFS, it runs on all edges and vertices that are reachable from the provided v, can be used with a visited array to will set to true for all nodes u that are reachable from v; Runtime is O(n+m) if run by itself

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

What is the Topological Sort algorithm used for?

A

This algorithm works by running DFS on the DAG (directed acyclic graph - it has no cycles) and using the post order number to sort the vertices from highest post number to lowest post number, when a DAG is ordered from source to sink, then all edges go from left to right; Runtime is O(n+m)

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

What is the Strongly Connected Components (SCC) algorithm used for?

A

It takes a directed graph and runs DFS twice, running once with pre/post order numbering on the reverse graph of G and sorting V in descending post order numbers, giving sink to source; It then runs again on G with V sorted, the output will have ccnum representing each SCC with highest = source, and lowest = sink, the ccnum can be used to gather up vertices that belong to each SCC; Runtime is O(n+m)

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

What is Kruskal’s Minimum Spanning Tree (MST) algorithm use for?

A

The algorithm sorts edges by weight of a connected and undirected graph, G = (V,E), and weights w, it grabs the lightest available edge that will not create a cycle when added to the MST, another way to look at this is to never add edges of vertices in the same component in the MST, this continues until all edges that will not create a cycle are added, this happens at exactly n-1 edges; Runtime is O(m log n)

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

What is a source vertex?

A

It has no incoming edges and has the highest post number

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

What is a sink vertex?

A

It has no outgoing edges and has the lowest post number

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

Vertices are strongly connected if?

A

There is a path from v -> w and w -> v

17
Q

In Conjunctive Normal Form (CNF), AND is represented by?

A

^ looks like an A

18
Q

In Conjunctive Normal Form (CNF), OR is represented by?

A

V looks like a V

19
Q

What inputs are taken to a max-flow algorithm?

A

G(V,E), s, t, c where s a source vertex, t is a sink vertex, and c is capacities; This set of inputs is also known as a Flow Network

20
Q

What are the steps involved in obtaining the max-flow of a graph?

A

Build a residual network of the graph that shows the capacities along edges; Check for any path in the residual network from s to t using DFS or BFS - if none is found, we’re done; If found, get the minimum capacity along the path; Augment the path by capacitive units along the path, forward edges are increased and backwards edges are decreased; Runtime is O(n+m)

21
Q

Describe the Ford-Fulkerson algorithm.

A

Assumes all capacities are positive integers, runs in rounds by increasing the flow >= 1 per round so there are C rounds where C is the size of max flow; Runtime is O(mC)

22
Q

Describe the Edmonds-Karp algorithm.

A

Very similar to Ford-Fulkerson except it uses BFS to determine the shortest path rather than “any path”; Runtime is O(nm^2)

23
Q

Does an MST contain cycles?

A

No, they are acyclic graphs (no cycles)

24
Q

What does the max flow - min-cut theorem state?

A

The size of the max flow equals the size of the minimum st-cut