CS 573 Homework 3 (due October 18, 2010) Fall 2010 CS 573: Graduate Algorithms, Fall 2010 Homework 3 Due Monday, October 18, 2010 at 5pm (in the homework drop boxes in the basement of Siebel) 1. Suppose we are given two arrays C [ 1.. n ] and R [ 1.. n ] of positive integers. An n × n matrix of 0s and 1s agrees with R and C if, for every index i , the i th row contains R [ i ] 1s, and the i th column contains C [ i ] 1s. Describe and analyze an algorithm that either constructs a matrix that agrees with R and C , or correctly reports that no such matrix exists. 2. Suppose we have n skiers with heights given in an array P [ 1.. n ] , and n skis with heights given in an array S [ 1.. n ] . Describe an efﬁcient algorithm to assign a ski to each skier, so that the average difference between the height of a skier and her assigned ski is as small as possible. The algorithm should compute a permutation σ such that the expression 1 n n X i = 1 ± ± P [ i ]-S [ σ ( i )] ± ± is as small as possible.
This is the end of the preview. Sign up
access the rest of the document.