Homework 2 - m , is minimized. 2 Page 173, Excercise 8.3-4....

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

View Full Document Right Arrow Icon
W07/CS592 Homework Two Design and Analysis of Algorithms Due: Feb. 13, 2007 There are four problems 1 There are n houses located on a west-east street. H[ i ] (meters), 1 i n , is the distance from the west-end of the street to the i th house. You may assume that H[1] < H[2] < H[3] < … < H[ n ]. There is no post office on the street. We plan to build several post offices on the street such that any house can reach a post office within 100 meters. Please design an O( n ) algorithm to compute the locations for the post offices, P[ j ] (meters), 1 j m , where P[ j ] is the distance from the west-end of the street to the j th post office. Make sure that the number of post offices,
Background image of page 1
This is the end of the preview. Sign up to access the rest of the document.

Unformatted text preview: m , is minimized. 2 Page 173, Excercise 8.3-4. Show how to sort n integers in the range 0 to n 2-1 in O( n ) time 3 Page 384, Exercise 16.2-3. Suppose that in a 0-1 knapsack problem, the order of the items when sorted by increasing weight is the same as their order when sorted by decreasing value. Give an efficient algorithm to find an optimal solution to this variant of the knapsack problem, and argue that your algorithm is correct. 4 Re-consider the problem of constructing the min-order binary tree for array A[1], A[2], …, A[ n ] in homework one. Please design a greedy algorithm that needs Θ ( n ) time in worst case. 1...
View Full Document

This note was uploaded on 04/12/2008 for the course CS 592 taught by Professor Shen during the Winter '05 term at University of Missouri-Kansas City .

Ask a homework question - tutors are online