{[ promptMessage ]}

Bookmark it

{[ promptMessage ]}

hw_sol_06 - CS 473 Fundamental Algorithms Spring 2011 HW 6...

Info icon This preview shows pages 1–3. Sign up to view the full content.

View Full Document Right Arrow Icon
CS 473: Fundamental Algorithms, Spring 2011 HW 6 Question 1 is due by Sunday, 23:59:59, March 13 Questions 2-4 are due by Monday, 23:59:59, March 14 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 HW6-Online and should be done individually. Note: You do not have to prove the correctness of your algorithms. In this solution, we give some key ideas (or steps) to prove the correctness. Please try to understand why your algorithms or the algorithms given here are correct. 1. HW6-Online. (20 pts.) 2. MST Stuff. (30 pts.) You are given an undirected weighted graph G = ( V, E ) with n vertices and m edges. Assume the weights of the edges are all distinct. (A) (10 pts.) Let E 0 E be the set of those edges of G with weight less than or equal to the median of edge weights. Give an O ( n + m ) time algorithm to determine whether the MST of G uses only edges in E 0 or not. Solution : Let G 0 = ( V, E 0 ) be the subgraph of G that has E 0 as edges and V as vertices. Using DFS, we can check whether G 0 is connected or not. We report that the MST of G uses only edges in E 0 if and only if G 0 is connected. Since we can construct G 0 in O ( m + n ) time and DFS takes O ( m + n ) time as well, we conclude the algorithm has O ( m + n ) running time. Note: Can you show the correctness using the “Reverse Delete Algorithm” in the lecture note (slide 8 / 54 in lecture note 12)? Rubrik : 10pts: Correct algorithm with running time O ( m + n ). Otherwise, if the write-up gives a key idea it gets 6pts. 1
Image of page 1

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

View Full Document Right Arrow Icon
(B) (20 pts.) Give an O ( n + m ) time algorithm that outputs the heaviest edge in the (unique) MST of G . Solution : Let e 1 , e 2 , ..., e m be the edges that are sorted in increasing order of weights. Let E i = { e 1 , e 2 , ..., e i } . Note that the heaviest edge in the MST of G is e i such that the graph ( V, E i ) is connected but the graph ( V, E i - 1 ) is disconnected. Hence our goal is to find such e i in O ( m + n ) time. Since all edges have distinct weights, if we know the weight
Image of page 2
Image of page 3
This is the end of the preview. Sign up to access the rest of the document.

{[ snackBarMessage ]}

What students are saying

  • Left Quote Icon

    As a current student on this bumpy collegiate pathway, I stumbled upon Course Hero, where I can find study resources for nearly all my courses, get online help from tutors 24/7, and even share my old projects, papers, and lecture notes with other students.

    Student Picture

    Kiran Temple University Fox School of Business ‘17, Course Hero Intern

  • Left Quote Icon

    I cannot even describe how much Course Hero helped me this summer. It’s truly become something I can always rely on and help me. In the end, I was not only able to survive summer classes, but I was able to thrive thanks to Course Hero.

    Student Picture

    Dana University of Pennsylvania ‘17, Course Hero Intern

  • Left Quote Icon

    The ability to access any university’s resources through Course Hero proved invaluable in my case. I was behind on Tulane coursework and actually used UCLA’s materials to help me move forward and get everything together on time.

    Student Picture

    Jill Tulane University ‘16, Course Hero Intern