graphs and MSTs Flashcards

(24 cards)

1
Q

What is a path in a graph?

A

A sequence of nodes which are connected by consecutive edges.

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

What defines a connected graph?

A

A graph is connected if there is a path between ANY two nodes.

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

What is a cycle in a graph?

A

A path that starts and ends at the same node, has at least 3 edges, and no other node appears more than once.

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

What is an acyclic graph?

A

A graph that has no cycles.

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

What is a tree in graph theory?

A

A graph with no cycles (acyclic).

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

What is a spanning tree?

A

A set of edges which connects all nodes of a graph and is acyclic.

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

Does every connected graph have a spanning tree?

A

Yes.

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

What are weighted edges in a graph?

A

Edges that have a cost/weight associated with them.

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

What is a minimum spanning tree (MST)?

A

A spanning tree whose cost (sum of edge costs) is no greater than other spanning trees.

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

Name two algorithms to find the MST of graphs.

A
  • Prim’s algorithm
  • Kruskal’s algorithm
How well did you know this?
1
Not at all
2
3
4
5
Perfectly
11
Q

What is a safe edge in Prim’s algorithm?

A

The least cost edge out of a tree that has grown so far.

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

What is the initial set of nodes in Prim’s algorithm?

A

R = {A, B, C, D, E, F} with S = {} and T = {}.

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

What is the time complexity of Prim’s algorithm using a priority queue?

A

O(E log E), where E is the number of edges.

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

What does Kruskal’s algorithm do?

A

Builds up a set of edges that don’t need to be connected.

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

What is a safe edge in Kruskal’s algorithm?

A

A minimal cost edge remaining that can be added without creating a cycle.

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

How do you track partitions in Kruskal’s algorithm?

A

By mapping elements to representatives of what set they are in.

17
Q

Fill in the blank: A tree is a graph with no _______.

18
Q

True or False: Kruskal’s algorithm can yield more than one outcome depending on the starting edge.

19
Q

What is the purpose of using a priority queue in graph algorithms?

A

To find and remove the minimal remaining edge each time through the loop.

20
Q

What happens if a chosen edge in Kruskal’s algorithm forms a cycle?

A

It is discarded.

21
Q

What is the initial partition of nodes in Kruskal’s algorithm?

A

{A} {F} {B} {C} {D} {E}.

22
Q

What does the variable T represent in Kruskal’s algorithm?

A

The set of edges which are a subset of a minimal spanning tree of G.

23
Q

What is required to check if an edge forms a cycle in Kruskal’s algorithm?

A

Check if the two nodes of the edge are already connected.

24
Q

What data structure is used to track connections in Kruskal’s algorithm?

A

A hashmap mapping elements to their representatives.