{[ promptMessage ]}

Bookmark it

{[ promptMessage ]}

Sol5a - CS 577 Introduction to Algorithms Homework Solution...

Info iconThis preview shows pages 1–2. Sign up to view the full content.

View Full Document Right Arrow Icon
CS 577: Introduction to Algorithms 11/28/06 Homework Solution: 5a Instructor: Shuchi Chawla TA: Siddharth Barman Question 1 The idea is to follow a clone of randomized quicksort. We have a set of nuts N and a set of bolts B . First we pick an element i of N uniformly at random and partition B using i , i.e. B is the set of bolts of size less than i and B + is the set of bolts of size greater than i . i serves as a future reference if the sizes of the two partitioned sets B and B + are comparable, in particular if min {| B | , | B + |} ≥ 1 4 | B | then we will use i and the matching bolt later. If the element picked does not satisfy the size constraints (of the partitioned sets) we randomly pick another. Note that any “well-centered” (pp. 730 of text) element satisfies this property and hence the expected number of steps before we find such an element is 2. We set N = N − { i } and partition N in N and N + using the matching bolt of i . Note that | N | = | B | and | N + | = | B + | . We recursively apply the same strategy to the two partitions. Note that the partition tree we construct is balanced on an average. Formally going down the tree the size of the sets decrease at least by a factor of 3 / 4. Hence if | B j | = n ( 3 4 ) m its depth is at most m . Hence time T spent on j N j is n ( 3 4 ) m . We have that the number of bolt set of size n ( 3 4 ) m is bounded by ( 4 3 ) m +1 . Hence total time spent for each type m is T × ( 4 3 ) m +1 = 4 3 n . As m is bounded by log n total time spent in expectation is O ( n log n ). Question 2 2a The strategy is to wait for the first half of the bids and determine the maximum among them. So we do not sell before we get to n 2 th bidder but we keep track of the max. bid seen so far say b max . After which we sell to the first bidder with a bid of more than b max in the second half. Consider the bids in increasing order i.e. b 1 b 2 ... b n and the seller sees them in order of a random permutation σ S n i.e. from b σ (1) to b σ ( n ) . The ideal case for us is when b n 1 is in the first half of σ and b n is in the second half, as b max is set to b n 1
Background image of page 1

Info iconThis preview has intentionally blurred sections. Sign up to view the full version.

View Full Document Right Arrow Icon
Image of page 2
This is the end of the preview. Sign up to access the rest of the document.

{[ snackBarMessage ]}