Gullu - Optimal Substructure and Handshaking Lemma Flashcards

1
Q

The edge a->b emanates from

A

a

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

The edge a->b is incident to

A

b

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

Adjacent Vertices

A

(in a->b the vertex b is adjacent to a)

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

Out-Degree of a Vertex:

A

Number of edges emanating from a node. Written as |A(v)|

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

In-Degree of a Vertex:

A

Number of edges incident on a node. Written as |I(v)|

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

The subgraph S of a graph G is a graph where

A
  • Each vertex in S is a vertex V of G
  • Each edge in S is a subset of the edges in G, and each vertex in edges of S is a vertex in S (implied because subgraph is a graph).
How well did you know this?
1
Not at all
2
3
4
5
Perfectly
7
Q

Connected Graph

A

There is a path between every pair of vertices.

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

Graph Representations

A

Common representations are the adjacency list and the adjacency matrix. Suppose the vertices of a graph are labelled with numbers 0 to n-1…

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

Adjacency List

A
  • Adjacency List would then be a 2D array (n by n) of Boolean values
  • A[i,j] true if there is an edge from i to j
  • If a graph is unweighted then a value in the matrix is the weight
  • If the graph is undirected, then A[i,j] = A[j,i]. This will make the matrix symmetrical about the diagonal.
How well did you know this?
1
Not at all
2
3
4
5
Perfectly
10
Q

Adjacency Matrix

A

the space complexity is O(|v|^2). This is irrespective of the number of edges in the graph. If |E| < |V^2| then the matrix will be sparse and inefficient, most values will be zero.

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

Suitability: Consider the operation of determining whether there is an edge between two vertices v1 and v2:

A

In adjacency matrix: Examine value of A[v1,v2]

In adjacency list: Locate v1 in the primary list, look for v2 in secondary list

Winner: Adjacency Matrix

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

Suitability: Find all vertices adjacent to a vertex v1 in a graph having n vertices

A

In adjacency matrix: Go to row for v1 and iterate over n columns

In adjacency list: Go to element v1 and the secondary list is the list of adjacency vertices

Winner: Adjacency list

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

The handshaking lemma

A

For undirected graphs, For example: There is a party in which some people shake hands, If i shake someones hand it follows that they shook my hand. There will be an even number of handshakes.

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

Spanning Trees

A

Concerns undirected and connected graph. A spanning tree is a tree that connects all the vertices in a graph and uses some edges.

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

The minimum spanning tree

A

Concerns connected and undirected graphs, The graph is weighted (edge weight function w:E->R).
The width of a spanning tree in the graph is the sum of weight it uses.
The minimum spanning tree is the spanning tree in the graph having the smallest weight.

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

Claim: MSTs have optimal substructure.

Derivations from proof:

A

If we repeatedly connect a subtree of an MST to the rest of the graph and always pick the smallest weight edge to do so, we’ll end up with the MST for the graph.

17
Q

Prim’s Algorithm

A
  • Create a priority queue Q that contains the vertices (v-a) where:
  • The weight of a node in Q is the lightest node going to a vertex in A
  • Initially A is empty
  • The weight of each node in Q will be ∞

So far…
- Q contains all of V (V-A actually, but A is empty)
- All weight of the nodes in Q ∞

  • Pick any node in Q and set its weight zero
18
Q

Total running time (Prim’s Algorithm)

A

O(V) x TimeTo(DequeueMin) + O(E) x TimeTo(UpdateKey). TimeTo() depends on the data structure we use to implement the queue