next up previous
Next: About this document

Fundamental Algorithms, Spring 1998

Assignment 4. Lower bounds on sorting and O(n) sorting.

Given February 11, due Monday, February 23.

1.
(from CLR, page 175) Show that it requires at least 2n-2 comparisons to merge two sorted lists of length n using only binary comparisons. This a problem of combinatorics. You need to know the number of different ways the two lists could be merged, that this number of ways is tex2html_wrap_inline38 or something like that. The number tex2html_wrap_inline40 is the number of subsets of a set of size n. If A and B are two subsets of the set tex2html_wrap_inline48 . The number of such pairs is tex2html_wrap_inline50 . Each pair corresponds to a different merging of the two lists. The merge starts with some numbers from list 1, then some from list 2, then more from list 1, then more from list 2 and so on. The subset A represents the indices from list 1 that start a streak of list 1 elements in the merged list. The B numbers represent the starts of streaks from the B list.
2.
(a widely used question) Show that radix sort can sort n numbers in the range tex2html_wrap_inline60 using O(n) storage and O(pn) work.
3.
a.
Suppose

equation13

that tex2html_wrap_inline66 , and that r(n) is the first k so that tex2html_wrap_inline72 . Show that tex2html_wrap_inline74 . Hint: Take the logarithm of both sides of (1).

b.
Let T(n) be the work required for a certain algorithm on input of size n. Suppose that

equation18

and that T(2) = 1. Show that tex2html_wrap_inline82 . Hint: Iterate the relation (2) until n gets to 2. Use part a to bound the number of iterates needed.

c.
Suppose there were a way to choose buckets n buckets in bucket sort so that the number of elements in each bucket would never exceed tex2html_wrap_inline90 . Show that a recursive sorting algorithm based on this would have work tex2html_wrap_inline92 .
d.
Suppose we select tex2html_wrap_inline94 elements from an unsorted list of length n, sort the selected elements, and use them as boundaries for buckets into which the rest of the elements of the list are inserted. Show that the number in each bucket is less than tex2html_wrap_inline90 with probability greater than tex2html_wrap_inline100 . If it were possible to select the bucket in constant time (as it is in bucket sort), this would give a probabilistic algorithm whose expected time to sort n numbers is tex2html_wrap_inline92 . In bucket sort, the bucket is selected using the key, assumed to be a floating point number, and taking the integer part. Note: This last step is very hard. I will post a hint next week.




next up previous
Next: About this document

Jonathan Goodman
Wed Feb 18 18:41:40 EST 1998