1. Limited time only! Sign up for a free 30min personal tutor trial with Chegg Tutors
    Dismiss Notice
Dismiss Notice
Join Physics Forums Today!
The friendliest, high quality science and math community on the planet! Everyone who loves science is here!

Homework Help: Minimum Spanning Tree - Algorithm

  1. Nov 23, 2009 #1
    1. The problem statement, all variables and given/known data
    Suppose a weighted connected graph G = (V,E) has n edges.
    Describe an algorithm to find a Minimum Spanning Tree of G in O(n) time. Prove the correctness of your answer. (Here n = |V |).

    2. Relevant equations
    I know about DFS, BFS, Prims algorithm

    3. The attempt at a solution
    I was thinking of running something similar to Breadth first search (BFS).
    Keep track of edges part of MST (call it EMST), and vertices part of MST (call it VMST)
    -select a vertex
    -look at all adjacent edges and find the one with minimum weight (by keeping a variable 'min' and updating it as we loop)
    -put the min edge in EMST, so we don't look at it again
    -put the current vertex and the other vertex connected by the edge both in VMST
    -then for all vertices in VMST repeat the procedure (so look at all of their vertices and find min to add to the VMST)

    I'm not sure if this procedure is O(n), i'm afraid it might be slower, but I can't think of a way to improve it. I'm also a bit unsure how to take advantage of n=|V|
  2. jcsd
Share this great discussion with others via Reddit, Google+, Twitter, or Facebook

Can you offer guidance or do you also need help?
Draft saved Draft deleted