Algorithms On Networks Flashcards
1
Q
Identify 2 algorithms to create a minimum spanning tree
A
- Kruskal’s algorithm
2. Primm’s algorithm
2
Q
What are the 4 steps to do Kruskal’s algorithm?
A
- Sort all arcs into ascending order of weight
- Select the arc of least weight to start the tree
- Consider the next arc of least arc that doesn’t form a cycle
- Repeat step 3 until all vertices are connected
3
Q
What are the 3 steps to do Prim’s algorithm?
A
- Choose any vertex to start at
- Select the arc of least weight that joins a vertex that is already in the tree to a vertex that isn’t in the tree
- Repeat step 2 until all vertices are connected
4
Q
Identify 3 differences between Kruscal’s and Prim’s algorithm?
A
- Prim can start at any point
- Prim can be used on a matrix
- Kruscal requires an ordered list of arcs
5
Q
Why do you not need to check for cycles when using Prim’s algorithm?
A
In Prim you add a new node to what you already have and are not adding arcs. Therefore if you add a new node each time you can’t make a cycle