Unformatted text preview: , 5 ,3 , 1 ,2] and k = 2, then the median element is 1, and the 2 elements in A with the smallest square distance to the median are { 1 ,2 } . If k = 3, then you can output either { 1 ,2 ,3 } or { 1 ,2 , 5 } . Hint: Use the linear time Selection algorithm. 2. (30 pts) Describe an O ( n log n ) time algorithm to compute the longest decreasing subsequence of a given sequence of n numbers. ( Hint : use an appropriate data structure to speed up the dynamic programming algorithm.) 3. (30 pts) Let T be rooted tree with integer lengths on its edges (they can be positive, negative or zero). Describe an algorithm that ﬁnds among all paths from a node in T to one of its descendants the one with the smallest length. The instance of the problem given below has the smallest path EFH of length9. A B C D E F G H I J 1 2545 227 3 1...
View
Full Document
 Fall '08
 Chekuri,C
 Algorithms, Dynamic Programming, 4 g, Selection algorithm, 30 pts, 5 2 J

Click to edit the document details