hw5-2010

# hw5-2010 - Problem 5-4. 10pts 1. 10pts Design an O ( n 2 )...

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

DFS/BFS, MST, Dynamic Programming November 16, 2010 Homework 5 Due Date: Tuesday, November 30, 2010, 2:05pm Problem 5-1. 10pts Explain how a vertex u of a directed graph can end up in a DFS tree containing only u , even though u has both incoming and outgoing edges in G . [Construct an example and explain why, in your example, u could end up as a single-node tree.] Problem 5-2. 15pts Given a graph G and a minimum spanning tree T , suppose that we decrease the weight of one of the edges in T . Show that T is still a minimum spanning tree of G . Now suppose we increase the weight of one of the edges not in T . Again, show that T is still a minimum spanning tree of G . Problem 5-3. 25pts Prove that a minimum spanning tree of a graph has the property that its heaviest edge weight is minimum over all spanning trees of G . In other words, prove that if your goal is to ﬁnd a tree that minimizes the weight of the heaviest edge, then MST is one of the possible solutions.
This is the end of the preview. Sign up to access the rest of the document.

Unformatted text preview: Problem 5-4. 10pts 1. 10pts Design an O ( n 2 ) algorithm to ﬁnd the length of the longest monotonically increasing subsequence of a sequence of n numbers. 2. Extra Credit Explain how to modify your algorithm to run in O ( n log n ) time. Problem 5-5. 15pts Design an O ( n 2 ) algorithm to ﬁnd the length of a longest subsequence that ﬁrst monotonically increases and then monotonically decreases. For example, if the input sequence is 1 , 7 , 4 , 9 , 5 , 3 , 8 , 7 , 2, then 1 , 4 , 3 , 2 is such a sequence, as well as 7 , 3 , 2 and 1 , 7 , 9. (Note that the second example misses ”increasing” part, and the third is missing the ”decreasing” part.) For this example, the answer is 6: (1, 7, 9, 5, 3, 2) or (1, 7, 9, 8, 7, 2). Problem 5-6. 25pts Solve problem CLRS 15.6, page 408 (Second edition: 15.4, page 367) 1...
View Full Document

## This note was uploaded on 02/01/2011 for the course MATH 171 taught by Professor R during the Spring '09 term at Stanford.

Ask a homework question - tutors are online