Note that there are some explanatory texts on larger screens.

plurals
  1. POUpdating a Minimum spanning tree when a new edge is inserted
    primarykey
    data
    text
    singulars
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. COMaybe I'm missing something -- surely G is connected so |V| <= |E| + 1? So your O(|V|) algorithm is automatically O(|E|) also, so where's the problem? Or are you saying, "I'm surprised I was able to solve it even better than the question asked me to"?
      singulars
    2. COYes, something like that! I'm surprised it's so simple to do in O(|V|) yet it asks it to be in O(|E|) in both questions. I fear there's something I'm not seeing. Also I have to give a proof of my solution and it's obvious that if e1 is the most expensive edge on a cycle then it can't be in the MST, and that if e2 is more expensive of e1 then e2 can't be in the graph, but can't the possibility of a new path throught e1 create a MST with edges that were in G but not in the previous MST T?
      singulars
    3. COUnless you've been told it, I don't think the property that no MST edge can be the longest edge in a cycle is "obvious". So I don't think the problem is "too easy". Re your proof question: suppose such an MST containing e1 existed. Then deleting e1 leaves 2 connected components. Because e1 was originally part of a cycle, there must be some other edge in that cycle that connects these 2 components (proving this part is left as an exercise :-P) and which has weight < w(e1). Add that edge to produce a smaller MST and thus a contradiction. So no MST containing e1 can exist.
      singulars
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload