# Theory of Algorithms

## Math 416, Fall 2005

Instructor: Loren Spice
E-mail: . Please include the string `416' in the subject line of any e-mail to this address.
Office: 3851 EH
Office phone number: 7347635301
Office hours: MW 2:30--3:30 PM and Th 12:30--1:30 PM, and by appointment
Anonymous feedback (or rate your professor).

Announcements and handouts will be available on this page. Since announcements may be posted at any time, you should check this page frequently. Make sure you hard refresh this page to ensure that you are not reading a cached version. Handouts will be PDF files, but are available to students in other formats upon request.

Course syllabus.
Most recent homework. Last updated 8 December. This homework will not be collected or graded.

Previous homeworks:

Handouts:

15th. The solution sets for Homeworks 9 and 10 are now available.
14th. Homework 10 is now graded and available for pickup. As a reminder, the exam room will be our usual room, 1068 EH.
13th. Homeworks will be available for pickup from the tray on my office door on Wednesday. Solution sets for Homeworks 9 and 10 will also be available this week. Office hours will be held as usual this week and Monday and Wednesday of next week. Office hours for Thursday next week will be moved to 9:30--10:30 AM, one hour before the exam.

In Friday's class, we discussed the algorithms Modular-Exponentiation(a, b, n), which computes Rem(ab, n) quickly and without storing large numbers; and the algorithm Base-2-PP, which is a (deterministic) primality test that can incorrectly identify its input as prime, but will never incorrectly identify it as composite.

In Monday's class, we discussed the refinement Miller-Rabin, which is a randomised algorithm that, on any input (even numbers which are base-b pseudoprimes for many b), has a high probability of success. As with Base-2-PP, the only error it can make is in incorrectly identifying a composite as prime (not vice versa).

8th (2:30 PM). The solution set for Homework 8 contained two errors, one minor and one serious. The minor error was in question 8, in which it was incorrectly claimed that we could choose a pair of badly-output elements of a merged array coming from different halves on the input. The serious error was in question 4, in which it was incorrectly claimed that the expected running time of a variant of Bucket-Sort was Θ(n2). In fact, the running time is Θ(n). Students who lost points for giving this answer should bring their homework me to receive full credit.
8th. In Monday's class, we turned our informal description of 2nd December into an algorithm, Recursive-FFT, for computing the discrete Fourier transform of a vector of length a power n of 2 in time Θ(n log n). Although we didn't discuss it in class, Section 30.3 of the text also discusses an iterative version of the F(ast)F(ourier)T(ransform).

We also discussed a way to make a parallel network, using butterfly transforms (three-input, two-output devices which, on input (a, b, c), produce output (a + b, c - b)), which computes the discrete Fourier transform in time Θ(log n). This is the last of the material which will be covered on the final exam.

In Wednesday's class, we began to discuss the idea of primality testing. For most numbers, the test `Rem(2n - 1, n) = 1?' is a good test for primality of the number n. If 2 is a bad choice of base, often another choice will provide a good test. However, there are some numbers resistant to all such tests. We will discuss this further in later classes. We also began to discuss modular exponentiation.

Homework for Monday was 30.2-6, 30.3-4 and 30-4(a, b, d). However, since this homework will not be collected, it should be viewed simply as practice for the exam. Also recommended were 30-1, 30-5 and 30-6.

2nd. In class today, we reviewed the polar form (z = r exp(iθ)) of complex numbers, and how to do arithmetic on them. We also showed how to compute the discrete Fourier transform of a vector of even length n by computing the discrete Fourier transforms of two vectors of half the length.

No new homework was assigned today.