Graphs and Trees Flashcards

1
Q

What is the definition of a graph?

A

A graph G is a set of vertices V and a set of edges E

Each edge in E is a pair (u,v) are vertices in V

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

What is adjacent and incident?

A

Adjacent: Two vertices are adjacent when connected by an edge

Incident: A vertice at either end of an edge is considered incident to that edge

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

Define:

  • walk
  • path
  • cycle
A

Walk: a sequence of alternating vertices and edges

Path: a walk in which no vertex is visited twice and no edge is used twice

Cycle: is a path that ends where it began (an edge joins the first and last vertex)

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

Define:

  1. connected
  2. disconnected
  3. components
A
  1. Connected : there exists a path between all vertices
  2. disconnected: there is not a path between all vertices
  3. components: when a graph is disconnected, each connected sub-graph is a component of the larger graph
How well did you know this?
1
Not at all
2
3
4
5
Perfectly
5
Q

What is:

  • A tree
  • A spanning tree

What are useful facts about a spanning tree?

A

Tree: A connected graph with no cycles

Spanning tree: subsets of a graph G that forms a tree (connected with no cycles)

Userful facts about spanning tree:

  • Every connected graph has a spanning tree
  • A spanning tree has N vertices and N-1 edges (a quick way to check if a spanning tree)
How well did you know this?
1
Not at all
2
3
4
5
Perfectly
6
Q

What is:

A weighted graph

Minimum spanning tree

A

weighted graph: a graph where each edge has a numeric value

minimum spanning tree: a weight graph G, whose set of edges has the least possible total weight when compared to all spanning trees in G

  • It is possible for a graph G to have multiple minimum spanning trees
How well did you know this?
1
Not at all
2
3
4
5
Perfectly
7
Q

Optimization Problem: Minimum Spanning Tree

What is the input?

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

Optimization Problem: Minimum Spanning Tree

What is the required output?

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

Optimization Problem: Minimum Spanning Tree : Solution

Let’s say we have a complete, connected graph on n vertices.

What is the number of spanning trees (feasible solutoions)?

A

There are nn-2 feasible solutions.

Among those, for a MST we are looking for the feasible solution with the minimum cost

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

Prim’s Algorithmm for MST

What is the general idea?

A

General idea: Exapnd the spanning tree one edge at a time

How:

At each step you have a connected tree T

Start with any single vertex in the graph then:

  • Make tree T bigger by adding the smallest-weight edge that has one connection inside of T and one endpoint outside of T
  • Repeat n-1 times
How well did you know this?
1
Not at all
2
3
4
5
Perfectly
11
Q

What does the mathy pseudo code for Prim’s MST algorithm look like?

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

What is the pseudo code for Prim’s MST Algorithm

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

MST Algo: Prim

How do you prove the greedy-choice property?

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

MST Algo: Prims

How do you prove the optimal substructure property?

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

what is the run time of prim’s algorithm?

A
17
Q

Kruskal’s Algo for MST

What is the general idea?

A
18
Q

MST Algo: Kurskal’s

What is the mathy speak pseudo code?

A
19
Q

MST Algo: Kruskal

What is the Pseudo code?

A
20
Q
A
21
Q

Prove the greedy choice property for MST Kruskal

A
22
Q

Prove the Optimal substructure for Kraskals

A
23
Q

Explain how Disjoint Set (Abstract Data Type) helps to implement kraskal’s algorithm

A
24
Q

What is the analysis runtime speed off Kruskal’s Algorithm?

A