Homework #2 -- due Monday Wk 3

# required problems topic
1 (Baase Exercise 1.41 on page 65)
Write out the algorithm to find X in an ordered array using the method that compares X to every fourth entry until X itself or an entry larger than X is found, and then, in the latter case, searches for X among the preceding three.  How many element comparisons does your algorithm do in the worst case?
search ordered list
2 (Baase Exercise 4.50 on page 216)
Give an efficient in-place algorithm to rearrange an array of N elements so that all the negative keys precede all the nonnegative keys.  How fast is your algorithm?
sorting
3 CLR Exercise 8.1-4 on page 168 sorting lower bound
4 CLR Exercise 6.4-3 on page 136 heapsort complexity

# suggested problems topic
5 CLR Exercise 8.1-3 on page 168 lower bound on sorting
6 CLR Exercise 8.2-2 on page 170 stability
7 Baase Exercise 1.50 on page 67 search
8 Baase Exercise 4.37 on page 214 heapsort
9 CLR Exercise 6.1-1 on page 129 heaps
10* Baase Exercise 1.47 on pages 66 searching unknown sized array
11* Linear-time solution for Baase Exercise 4.59a on page 218 maximum profit window in 2D
12* Consider a rectangular array.
Sort the elements in each row into increasing order.
Next sort the elements in each column into increasing order.
Prove that the elements in each row remain sorted.
shellsort basis


Dan Hirschberg
Computer Science Department
University of California, Irvine, CA 92697-3435
dan at ics.uci.edu
Last modified: Jun 18, 2008