This preview shows page 1. Sign up to view the full content.
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
This note was uploaded on 01/22/2011 for the course CS 473 taught by Professor Chekuri,c during the Fall '08 term at University of Illinois, Urbana Champaign.
 Fall '08
 Chekuri,C
 Algorithms

Click to edit the document details