This preview has intentionally blurred sections. Sign up to view the full version.
View Full Document
Unformatted text preview: CS 473: Fundamental Algorithms, Spring 2011 HW 5 Question 1 is due by Saturday, 23:59:59, March 5 Questions 23 are due by Sunday, 23:59:59, March 6 Question 4 is due by Monday, 23:59:59, March 7 This homework contains four problems. Read the instructions for submitting homework on the course webpage . Collaboration Policy: For this homework, Problems 2–4 can be worked in groups of up to three students. Problem 1 should be answered in Compass as part of the assessment HW5Online and should be done individually. 1. HW5Online. (10 pts.) 2. Matching in a tree. (40 pts.) Let G = ( V,E ) be an undirected graph with weights on the edges. For example, for an edge uv ∈ E , we have a weight w ( uv ) associated with uv . A subset M ⊆ E of edges in G is a matching , if no pair of edges of M share an endpoint; that is, every vertex is contained in at most one edge of M . We are interested in the problem of computing the maximum weight matching in G . In general, this problem can be solved efficiently, but the algorithm is quite complicated. Fortunately for the tree case this is much easier. Describe an efficient algorithm, as fast as possible, for computing the maximum weight match ing when G is a tree. Solution : First note that we can pick an arbitrary vertex r of our tree as the root, and run DFS to obtain a rooted tree T . For a vertex v of the tree T , let C ( v ) be the set of its children. Also let M [ v ] indicate the weight of a maximum matching for the subtree rooted at v . We are going to write M [ v ] in terms of value of M at descendants of v (effectively reducing to optimal subproblems). Consider some optimal matching. We have two cases to consider: • In this optimal matching v is matched to one of its children u . Therefore under this matching, all the subtrees rooted at other children of v and rooted at children of u are optimally matched (They are matched by the definition of matching, and each of them is optimal because if not, replacing it with some optimal matching will give us 1 a heavier matching for the whole tree, a contradiction). Hence for this case we have M [ v ] = w ( vu ) + ∑ w ∈ C ( v ){ u } M [ w ] + ∑ w ∈ C ( u ) M [ w ]....
View
Full Document
 Spring '08
 Chekuri,C
 Algorithms, Graph Theory, optimal solution, Bipartite graph, Optimal Matching, curChild

Click to edit the document details