Algorithms on networks Flashcards

1
Q

What does Kruskal’s algorithm do?

A

It finds the minimum spanning tree

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

What is a minimum spanning tree?

A

A spanning tree such that the total length of its edges is as small as possible

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

Explain Kruskal’s algorithm

A

Sort all of the edges into ascending order of weight. For each edge, if it would not form a cycle with the already selected edges, add it to the tree. Otherwise, reject it. Repeat this until all vertices are connected

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

What does Prim’s algorithm do?

A

It finds the minimum spanning tree

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

Explain Prim’s algorithm

A

Choose any vertex to start the tree. Then select the edge of least weight that joins a vertex that is already in the tree to a vertex that is not yet in the tree (if there are multiple to choose from, pick randomly). Repeat this until all vertices are connected

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

Explain how Prim’s algorithm can be used with matrices

A

Choose any vertex to start the tree. Delete the vertex’s row, and number its column. Then, until all rows have been deleted, circle the lowest undeleted entry in any of the numbered columns, delete its row and numbers its column. Once this has been completed, the circled entries will be the edges of the minimum spanning tree

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

What does Dijkstra’s algorithm do?

A

Finds the shortest route between two vertices

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

Explain Dijkstra’s algorithm

A

Label the start vertex’s final value as 0. Then, until the end vertex receives its final value: for every vertex Y that is joined to the vertex X that has just received its final value, if X’s final value + length of XY < Y’s current working value, update Y’s current working value. Once all vertices joined to X have been considered, the vertex with the lowest working value has its final value set to its working value. When the end vertex receives its final value, a backtrace is performed; starting at the end vertex, and letting B equal the last chosen vertex, include edge AB whenever B’s final value - length of AB = A’s final value. The edges produced by this form the shortest path

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