Graphs Flashcards

1
Q

When is an graph connected?

A
  • undirected
  • > =1 vertex
  • there’s a path between every pair of vertices
How well did you know this?
1
Not at all
2
3
4
5
Perfectly
2
Q

What is the complexity of Dijkstra’s shortest path algorithm when using an Adjacency list and PQ?

A

O((n+e)*log(n))

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

Dijkstra pseudo code

A
(min distance from v to all)
while PQ not empty
 -remove u with min distance from PQ
 -for each adjacent vertex z
  -if D[u] +w(u,z)
How well did you know this?
1
Not at all
2
3
4
5
Perfectly
4
Q

What kinda graph does Bellman-Ford shortest path algorithm work on?

A

Directed

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

What makes Bellman-Ford different from Dijkstra?

A

negative weights allowed

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

Complexity of Bellman-Ford algorithm?

A

O(n*e)

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

How would you define a graph (informal)?

A

A set of nodes

  • containing some USEFUL INFOrmation
  • connected by edges
How well did you know this?
1
Not at all
2
3
4
5
Perfectly
8
Q

How would you define a graph (formal)?

A

G(E,v)

  • Set of V vertices
  • Collection E oF PAIRS of vertice, edges
How well did you know this?
1
Not at all
2
3
4
5
Perfectly
9
Q

What is the complexity of Dijkstra when using a list as a priority queue?

A

O(n^2)

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

When is a digraph strongly connected?

A

if v is reachable from u, u is reachable from v

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

What is the transitive closure of a graph G?

A
  • G* that has the same vertices as g

- wherever there’s a path from (u,v) in G, G* has an edge

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

What is the algorithm to compute the transitive closure called?

A

Floyd-Warshall

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

The floyd warshall algorithm makes an initial copy of G and then traverses all nodes and their reachable pairs.

What 3 conditions needs to hold for it to add a directed edge (Vi,Vj) to Gk?

A

Edge (Vi,Vj) exists in Gk-1 (prev graph)
Edge (Vj,Vk) exists in Gk-1
Edge doesn’t already exist in Gk

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

What is the asymptotic time complexity of the Floyd Warshall algorithm?

A

O(n^3)

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

What is the degree of a vertex?

A

number of edges incident to it

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

What does a spanning subgraph have?

A

Same nodes but a subset of edges

17
Q

What is a forest?

A

graph without cycles

18
Q

What is traversal?

A

A systematic procedure for visiting all edges and nodes in a graph

19
Q

Which is recursive, DFS or BFS?

A

DFS

20
Q

What do nodes of a level in BFS have in common?

A

same distance from a fixed node

21
Q

Both BFS and DFS have the same complexity which is?

A

O(n+e)

22
Q

How are live objects signified in the mark and sweep algorithm?

A

mark

23
Q

How is the digraph connected to the mark and sweep algorithm?

A

Each object in memory heap is a vertex

Each reference is an edge

24
Q

What does the mark phase of mark and sweep involve?

A

1.Directed DFS on root objects to identify live objects

25
Q

What does the sweep phase involve?

A
  1. Sweep through Memory heap

2. Reclaim space from unmarked objects

26
Q

What is a eulerian trail or path?

A

A path in a finite graph the visits every Edge Exactly once

27
Q

What is a eulerian circuit in a graph?

A

A eulerian trail that starts and ends at the same vertex

28
Q

What is the chinese postman problem?

A

Find a shortest closed path (or circuit) that visits every edge of a connected undirected graph

29
Q

What is the eulerian trail’s connection to the CPP?

A

IT is the optimal solution