You have eight problems, and 14 days to do them.
As you're doing these, think of which one you'd like to present in class, and let me know as soon as you've decided. Solutions will be presented in class March 3 and 5.
Here's a silly way to sort a bunch of numbers: generate each of the possible permutations of the numbers, and for each one, test whether it's in order.
Analyze this algorithm: tell how long it takes, as a function of how many numbers there are, using big-O notation.
A slightly less-silly way to sort: for each number, count how many of the other numbers are less than it, and use this count to put it into the right location in an array. Then read off the array from beginning to end.
Analyze this algorithm: tell how long it takes, as a function of how many numbers there are, using big-O notation. Do you see any significant limitations of this algorithm? Can you fix them?
CLRS problem 4-5 (chip-testing, at the end of the chapter)
From another textbook: Suppose you have a bunch of numbers stored in two n-element sorted arrays, and you want to find the n-th smallest element (i.e. approximately the median) of the combined collection of numbers. You have random (read) access to the arrays, so you can get the k-th smallest element from either array in constant time.
Give an algorithm to find the median of the combined collection of numbers in O(log(n)) time.
From another textbook: Suppose you have a bunch of identical glass jars, and you want to find out (to the nearest foot) how long a drop they can take without breaking. Assume that whether they break is unaffected by wind, temperature, angle, history of previous non-breaking drops, etc.; it's solely determined by the height of the drop.
Implement (in a language of your choice) a data structure for matrices that allows you to extract contiguous sub-matrices (say, rows 3-6 and columns 4-8 of a given matrix) in constant time.
Next, implement (in the same language) three different algorithms for matrix multiplication:
Run all three algorithms on random matrices of a variety
of (power-of-2) sizes.
Check that all three algorithms produce the same answer
(or, if you're using floating-point, very close to the same answer).
Tabulate the CPU time taken by each algorithm at each
input size? What conclusions can you draw?