04 - Minimum Spanning Tree (Solution)

04 - Minimum Spanning Tree (Solution) - The Hong Kong...

Info iconThis preview shows page 1. Sign up to view the full content.

View Full Document Right Arrow Icon
This is the end of the preview. Sign up to access the rest of the document.

Unformatted text preview: The Hong Kong University of Science & Technology COMP 271: Design and Analysis of Algorithms Fall 2007 Tutorial 4: Minimum Spanning Tree Answer Either of the following two questions in the first 20 minutes. The TA will discuss the answers in the remaining 30 minutes. Question 1 : Let G be a connected undirected graph with weights on the edges. Assume that all the edge weights are distinct. Prove that the edge with the smallest weight must be included in any minimum spanning tree of G. You have to prove this from first principles, i.e., you are not allowed to use the MST Lemma or assume the correctness of Prim’s or Kruskal’s algorithm. Suggested proof: We can prove it by DERIVING A CONTRADICTION. * Suppose that the edge with the smallest weight, denoted as e is NOT in the minimum spanning tree (MST). * Let T be the MST, so T does not contain e. * We add e to T , this creates a cycle. e e MST T ′ Add e to T, this creates a cycle * Let e be any other edge on this cycle. Since e is the smallest weight edge in the graph and edge weights are distinct, so we have w(e′ ) > w(e). 1 * So, let’s break the cycle by removing (e′ ) from T and we restore a spanning tree, call it T ′ = T ∪ {e} − {e′ }. e e Remove e to restore a spanning tree T * And the weight of T ′ is as follows. w(T ′ ) = w(T ) + w(e) − w(e′ ) * Since e is the edge with smallest weight, we have w(e) < w(e′ ). Thus w(T ′ ) < w(T ). This contradicts with the assumption that T was a MST. Thus, the edge with the smallest weight must be included in any minimum spanning tree of G. Proved! 2 Question 2 : (a) Show each step in executing Prim’s algorithm to find a minimum spanning tree for weighted graph G. Use arrows on edges to indicate predecessor pointers, numeric label in each vertex to represent its key value and black colored nodes to show those vertices in the tree. Note: The first step has been done for you. ( i denote +∞ ) Connected Graph G 8 4 11 8 7 1 2 2 6 4 14 10 7 9 Step 1 (Given) 4 4 11 8 7 1 8 2 i 6 7 4 i 14 9 i i i 10 8 i 2 Step 2 8 4 11 8 2 Step 3 8 6 7 4 i 14 8 9 4 2 11 8 7 4 7 14 9 i 7 1 i i 10 2 7 1 6 i 4 10 8 i 2 8 i 2 Step 4 8 4 11 8 2 6 7 1 4 7 Step 5 7 14 8 9 4 2 11 8 6 7 1 4 7 7 14 9 i 4 10 10 10 7 6 2 7 2 2 3 Step 6 8 4 11 8 2 6 7 1 2 4 7 Step 7 7 14 8 9 4 11 8 7 1 2 2 6 4 7 7 14 9 10 10 10 10 1 Step 8 8 4 11 8 7 1 2 2 6 4 14 7 9 Step 9 8 4 2 11 8 7 1 2 6 4 14 10 7 9 9 10 Total edge weight of the spanning tree produced = 37 4 (b) Is your minimum spanning tree produced in part (a) unique? No, it is not unique. Another possible minimum spanning tree for Graph G is as follows. Connected Graph G 8 4 11 8 7 1 2 2 6 4 14 10 7 9 Step 1 (Given) 4 4 11 8 7 1 8 2 i 6 7 4 i 14 9 i i i 10 8 i 2 Step 2 8 4 11 8 2 Step 3 8 6 7 4 i 14 8 9 4 2 11 8 7 1 8 6 7 4 i 14 9 i 7 1 i i 10 7 i i 10 8 i 2 1 2 5 Step 4 8 4 11 8 7 1 2 2 Step 5 8 6 7 4 i 14 8 9 4 2 11 8 7 1 4 6 7 4 2 14 14 9 6 i 10 6 10 10 2 Step 6 8 4 11 8 7 1 2 2 7 4 Step 7 7 14 8 9 4 2 11 8 7 1 2 6 4 7 7 14 9 2 6 10 10 10 10 Step 8 8 4 11 8 7 1 2 2 6 4 14 7 9 Step 9 8 4 2 11 8 7 1 2 6 4 14 10 7 9 9 10 Total edge weight of the spanning tree produced = 37 6 ...
View Full Document

Ask a homework question - tutors are online