Reputation: 1
Let G = (V, E) be a weighted undirected connected graph, where all the edge weights are distinct. Let T denote the minimum spanning tree.
Suppose that G has m ≤ n + 157 edges. For this special case, give an MST algorithm that runs in O(n) time beating Kruskals and Prims algorithm.
Any hints?
Upvotes: 0
Views: 2234
Reputation: 59174
First verify that the graph is connected.
Then repeat until the graph is a tree (# edges = n-1):
When done you are left with the MST.
Even though this can take O(n) time per iteration, there will be at most 158 iterations, so that is still O(n) all together.
Upvotes: 0