September's homeworks:

26th. Class today was cancelled, since (I guess) almost everyone was at the career fair. CLRS 5.3-2, 5.3-3, C.1-11, C.2-9, C.3-2 and C.3-9 will be assigned on Wednesday. (The last four problems come from Appendix C.)
25th. Please note that the most recent homework has been updated with the assignment from Friday. There is now a note indicating when the most recent homework was updated, as well as when it is due.
23rd. Today we discussed a general method for solving recurrences of the form T(n) = a T(n/b) + f(n), where a and b are appropriate integers and f is a suitable nonnegative function. Most functions f are covered, but we will see on Monday that there are some which `fall through the cracks'. The result that establishes this general method is known as the Master Theorem, and is the subject of Section 4.3 (and proved in Section 4.4).

Homework for today is CLRS 4.3-2 and 4-6.

21st. Today we discussed using recurrence trees to arrive at a guess for the solution to a recurrence. We also discussed the technique of under- and over-estimating a recurrence by estimates which have the same rate of growth, hence `sandwich' the recurrence itself in the middle. Homework for today is CLRS 3-4, 4.1-5, 4.1-6, 4.2-4 and 4-5. Add the words `Justify your answer by using the substitution method' to the statement of 4.2-4. Also recommended (but not required) are 3-1, 4.2-5, 4-1 and 4-4.
19th. Today we discussed how divide-and-conquer problems give rise to recurrences, i.e., expressions which describe the worst-case running time on a given input in terms of the worst-case running times for smaller inputs. We will be interested almost exclusively in asymptotically correct solutions to recurrences, not exact solutions. We also described the `substitution' (really guess-and-check) method, which allows us to verify that an apparent (asymptotic) solution to a recurrence really is an (asymptotic) solution. No homework was assigned.

We will discuss one means of arriving at a guess (which can be checked with substitution) on Wednesday.

16th. The three exams will be held on Friday, October 14; Friday, November 18; and Thursday, December 22.

After a brief discussion of Merge-Sort, pointing out that it is asymptotically faster than Insertion-Sort but uses more memory, we introduced the asymptotic notations O, o, Ω, ω and Θ, and the relations among polylogarithms, polynomials and exponentials that can be asserted using them. We also discussed modular arithmetic and the Rem operator (called Mod in the text).

A new problem was added to this week's homework.

14th. Today we used a loop invariant to prove that Merge worked correctly to merge two sorted arrays into a single sorted array, then used Merge as a subroutine in a recursive sorting algorithm Merge-Sort. We found the running time of Merge-Sort on arrays of length a power of 2 by looking at a recursion tree. No homework was assigned.

The homework assigned on Monday has now been included below. If you are not using the second edition of CLRS, please note that some problem numbers are different, so you should make sure to download the handout and check that you are doing the correct problems. If your copy of the homework handout has problem 2.3-5 beginning `Observe that the while loop ...', this is an old version. The correct version has the problem beginning `Referring back to the searching problem ...'. This is the problem you should do.

12th. Due to a typo, the `if j = 0' test in the handout `Correctness of Insertion-Sort' appeared inside, rather than outside, the inner for loop. If the test on your handout appears on line 10 (rather than line 11), please download the new copy or correct your copy. Today we analysed the worst-case running time of Insertion-Sort and wrote pseudocode for Merge, an important subroutine of Merge-Sort. Homework for today is CRLS 2.2-2, 2.3-5, 2-2 and 2-3.
9th. Today we converted our English-language discussion of Insertion-Sort into pseudocode and proved its correctness using the technique of identifying a loop invariant and then showing that initialisation, maintenance and termination all work correctly. A handout is available above.

No homework was assigned this week.

7th. Today we introduced the sorting problem: Given an array $A$ consisting of (say) numbers, return an array $A\text{'}$ whose entries are the same as those of $A$, except in sorted order. We discussed Selection-Sort (which moves successive smallest elements of the array to their proper place in the array) and Insertion-Sort (which inserts successive elements into the array) in English. No homework was assigned.