I start at 0 so that when we get to chapter 1, the numbering will agree with the text.
There is a web site for the course. You can find it from my home page.
The course text is Goodrich and Tamassia: ``Algorithm Design: Foundations, Analysis, and Internet Examples.
The grades is computed as
30% midterm, 30% problem sets, 40% final exam.
We will have a midterm. As the time approaches we will vote in class for the exact date. Please do not schedule any trips during days when the class meets until the midterm date is scheduled.
If you had me for 202, you know that in systems courses I also assign labs. Basic algorithms is not a systems course; there are no labs. There are homeworks and problem sets, very few if any of these will require the computer. There is a distinction between homeworks and problem sets.
Problem sets are
I run a recitation session on Tuesdays from 2-3:15 in room 102. There is another session on Thursdays from 9:30-10-45 in room 109. You should only attend one.
Good methods for obtaining help include
I use the upper left board for homework assignments and announcements. I should never erase that board. Viewed as a file it is group readable (the group is those in the room), appendable by just me, and (re-)writable by no one. If you see me start to erase an announcement, let me know.
It is university policy that a student's request for an incomplete be granted only in exceptional circumstances and only if applied for in advance. Naturally, the application must be before the final exam.
We are interested in designing
algorithms (a step-by-step procedure for performing
some task in a finite amount of time) and
data structures (a systematic way of organizing and
Unlike v22.102, however, we wish to determine rigorously just how good our algorithms and data structures really are and whether significantly better algorithms are possible.
We will be primarily concerned with the speed (time complexity) of algorithms.
We will emphasize instead an analytic framework that is independent of input and hardware, and does not require an implementation. The disadvantage is that we can only estimate the time required.
Homework: R-1.1 and R-1.2 (Unless otherwise stated, homework problems are from the last section in the current book chapter.)
Designed for human understanding. Suppress unimportant details and describe some parts in natural language (English in this course).
The key difference between the RAM model and a real computer is the assumption of a very simple memory model: Accessing any memory element takes a constant amount of time. This ignores caching and paging for example. (It also assumes the word-size of a computer is large enough to hold any address, which is generally valid for modern-day computers, but was not always the case.)
The time required is simply a count of the primitive operations executed. A more sophisticated analysis might count some primitive operations as more expensive than others. There are many possible sets of primitive operations. For this course we will use
Let's start with a simple algorithm (the book does a different simple algorithm, maximum).
Algorithm innerProduct Input: Non-negative integer n and two integer arrays A and B of size n. Output: The inner product of the two arrays. prod ← 0 for i ← 0 to n-1 do prod ← prod + A[i]*B[i] return prod
The total is thus 1+1+5n+2n+(n+1)+1 = 8n+4.
Homework: Perform a similar analysis for the following algorithm
Algorithm tripleProduct Input: Non-negative integer n and three integer arrays A. B, and C each of size n. Output: The sum A*B*C + ... + A[n-1]*B[n-1]*C[n-1] prod ← 0 for i ← 0 to n-1 do prod ← prod + A[i]*B[i]*C[i] return prodEnd of homework
Let's speed up innerProduct (a very little bit).
Algorithm innerProductBetter Input: Non-negative integer n and two integer arrays A and B of size n. Output: The inner product of the two arrays prod ← A*B for i ← 1 to n-1 do prod ← prod + A[i]*B[i] return prod
The cost is 4+1+5(n-1)+2(n-1)+n+1 = 8n-1
THIS ALGORITHM IS WRONG!!
If n=0, we access A and B, which do not exist. The original
version returns zero as the inner product of empty arrays, which is
arguably correct. The best fix is perhaps to change
Positive in the Input specification.
Let's call this algorithm innerProductBetterFixed.
What about if statements?
Algorithm countPositives Input: Non-negative integer n and an integer array A of size n. Output: The number of positive elements in A pos ← 0 for i ← 0 to n-1 do if A[i] > 0 then pos ← pos + 1 return pos
Let U be the number of updates done.