Lecture 3 - Prim-Jarnik Algorithm Flashcards
1
Q
What kind of an algorithm is the prim-jarnik algorithm?
A
A greey algorithm, it makes decisions based on local optimality in order to get a globally optimal solution.
2
Q
What is the complexity of this algorithm?
A
O(n^3)
- initialisation of vertices into ntvs and tvs is O(n)
- Outer while loop is executed n-1 times, this is O(n)
- Inner loop goes through all edges between vertices, there can be n^2 of these, so O(n^2)
- updating tree is O(1)
3
Q
What is a tv ?
A
tree vertex
4
Q
What is an ntv?
A
non- tree vertex
5
Q
How does the algorithm work?
A
- set one vertex to be a tv
- set all other vertices to be ntvs
- until all vertices are tvs
find smallest edge from tv to ntv
mark edge , add weight
add that ntv to tvs