hw_7_soln - CS 473: Algorithms, Fall 2010 HW 7 (due...

Info iconThis preview shows pages 1–2. Sign up to view the full content.

View Full Document Right Arrow Icon
CS 473: Algorithms, Fall 2010 HW 7 (due Tuesday, October 26th) This homework contains four problems. Read the instructions for submitting homework on the course webpage . In particular, make sure that you write the solutions for the problems on separate sheets of paper; the sheets for each problem should be stapled together. Write your name and netid on each sheet. Collaboration Policy: For this home work, Problems 1-3 can be worked in groups of up to 3 students each. Problem 0 should be answered in Compass as part of the assessment HW7-Online and should be done individually. 1. (25 pts) Let G = ( V,E ) be an undirected graph with edge costs c e . Given an integer k where 1 k n - 1, describe an algorithm that finds the minimum-cost forest in G that contains k edges. Solution : In order to find a minimum-cost forest in G, we simply run Kruskal’s algorithm until k edges are inserted. The running time will be O ( m log m ) since this is the running time for Kruskal’s, and we also need this much time in order to sort the edges. Note, if you interpreted the question to mean “the minimum-cost forest with at least k edges”, then you should continue running Kruskal’s algorithm past the point of k edges as long as the edge weights are negative. Now we must prove this algorithm is correct. Clearly it returns a forest, since at any point in Kruskal’s algorithm we have a forest. Let F be the forest that our algorithm returns. Suppose that there was a Forest, F 0 , with k edges that was cheaper, and let e j be the minimum weight edge such that e j is in F but not in F 0 . Specifically, let F 0 be the optimal forest that maximizes the value of j in the list of edges sorted by increasing weight, e 1 ,...,e m . Consider adding e j to F 0 . If e j does not create a cycle in F 0 , then we can simply add e j and remove the heaviest weight edge in F 0 to obtain a cheaper forest with k edges, which contradicts the optimality of F 0 . So assume that adding e j creates a cycle, C . We know that for all i such that i < j , e i is in both F and F 0 . Since F did not contain a cycle with e j , there must be some edge
Background image of page 1

Info iconThis preview has intentionally blurred sections. Sign up to view the full version.

View Full DocumentRight Arrow Icon
Image of page 2
This is the end of the preview. Sign up to access the rest of the document.

This note was uploaded on 04/18/2011 for the course CS 473 taught by Professor Chekuri,c during the Spring '08 term at University of Illinois, Urbana Champaign.

Page1 / 4

hw_7_soln - CS 473: Algorithms, Fall 2010 HW 7 (due...

This preview shows document pages 1 - 2. Sign up to view the full document.

View Full Document Right Arrow Icon
Ask a homework question - tutors are online