CMPSCI 311: Theory of Algorithms
David Mix Barrington
This is the home page for CMPSCI 311.
CMPSCI 311 is the undergraduate core course in
the theory of algorithms and will deal with
methods of analysis, four major algorithmic paradigms,
NP-completeness, and ways to deal with NP-hard problems.
textbook is Algorithm Design by Jon Kleinberg and Eva Tardos
(Addison Wesley, first edition 2006, ISBN 0-321-29535-8). I have ordered copies
at the Jeffrey Amherst College Store in
downtown Amherst (26 S. Prospect Street, accessible from the Common through
the alley between Hastings and La Veracruzana). The
book is also available through online retailers. This is the first time this
book has been used at UMass -- the other texts by Cormen-Leiserson-Rivest-Stein
and Levitin may be of use as references but they are not the text for
the course. You will need a copy of Kleinberg-Tardos as I will be lecturing
out of it fairly closely and the homework assignments will mostly come from
Important Course Material (as it becomes available):
Announcements (15 January):
- (15 Jan) The final exam solution is now
posted. You may pick up graded finals from me in my office - I will keep them
through the spring term at least. I also have some graded homework and
discussions that you can pick up as well. (We've stopped distributing graded
work through the CMPSCI main office, partly because doing so properly according
to the grade-privacy rules places too great a burden on them.)
I really enjoyed having you all in the course -- please keep in touch and
feel free to check with me for any advising issues.
- (10 Jan) Well, I filed the grades and emailed your individual grades on
time, then got behind on posting the exam and solution.
Here's the exam itself, and I'll try to get the
solution posted tomorrow.
The scale on the exam was 95 for an A, 57.5 for a C. The exam scores in
order were 106, 101, 90, 88, 80, 73, 72, 71, 70, 69, 66, 66,
61, 61, 60, 59, 58,
57, 54, 50, 50, 49, 46, 43, 42, 33. Of the 26 people who took the final, I
gave 3 A's (one of them an unofficial A+), one A-, no B+, five B's, six B-'s,
three C+, five C's and three C-'s.
- (30 Dec) I'm still grading, as I didn't accomplish as much as I'd hoped
while I was out of town. I'll post the exam and solutions once I'm done. I
will send a brief email to each of you with your exam grade and overall grade --
this has to happen before grades are due at noon on Tuesday.
- (15 Dec) Here are solutions to the
- (12 Dec) Robert will have the solutions to HW#6 available sometime
on Thursday. I will be around and available much of the day on Thursday,
including my normal office hours 11-12. I will be away for most of Friday
at a workshop, but I will be reading email over the weekend and will be in
on Monday most of the day.
- (12 Dec) I have posted the practice final
exam. The real final will be similar in length and difficulty, except that
I will probably have three or four true/false questions rather than two -- this
might have the effect of making it shorter.
- (7 Dec) I have posted notes for this week's
discussion. Next week's discussion will be course evaluations, both the
university form and essay questions for me. Attendance will count as usual
for a discussion -- any serious response to the essay questions will get a
- (3 Dec) I should also correct something I said in Friday's lecture, which
was that the makespan problem becomes polynomial-time solvable when the sizes
of the items are polynomial-size integers. In fact the makespan problem, like
the bin-packing problem we will see in this week's discussion, is
complete, which means that the polynomial-sizes-only version is also
NP-complete. This is in contrast to the SUBSET-SUM problem, which we saw to
be solvable if the entries were bounded by a polynomial in n.
- (3 Dec) In Friday's lecture I was asked for an example showing that the
Sorted-Balance on page 605 of KT performs badly in general. (KT shows that
it never achieves worse than 3/2 the optimal makespan.) The correct bound for
large m (number of machines) is actually 4/3 rather than 3/2, as KT note on
page 659. Here is a family of bad examples:
- m=2: 3, 3, 2, 2, 2. Optimal makespan is 6, sorted-balance gets 7.
- m=3: 5, 5, 4, 4, 3, 3, 3. Optimal is 9, sorted-balance gets 11.
- m=4: 7, 7, 6, 6, 5, 5, 4, 4, 4. Optimal is 12, sorted-balance gets 15.
- General m: 2m+1 jobs, two each with 2m-1, 2m-2, ..., m+1, three with m.
Optimal score is 3m, sorted-balance gets 4m-1.
This is actually the worst possible performance of sorted-balance for each
m, as can be shown by a slight adaptation of the argument in KT. In fact the
sorted-balance algorithm always achieves the optimal makespan for n (the number
of jobs) up to 2m. For n ≥ 2m+1, the optimum must be at least three times
the size tn of the last job, since one machine must have at least
three jobs. Also, the difference between the largest and smallest total
machine load must be at most tn, except in the special case where
the makespan is the size of the largest job, where sorted-balance is optimal.
Since the optimum must be at least the average, which must be at least the
minimum load plus tn/m, the sorted-balance performance must be within
tn(1 - 1/m), and the sorted-balance makespan must be at most
(4 - 1/m)/3 times the optimum.
- (30 Nov) Notes for Discussion #10, from this
week, are now up.
- (29 Nov) I have posted the last homework assignment.
Note two things:
I next owe you notes for Discussion #10.
- This is due on the last day of classes, and you may hand it
in to the main office as late as 4:30 p.m. or to me in class as usual.
- There are 110 points worth of problems instead of the usual 100, so you
have a chance to earn some extra credit. Grading will be on the usual scale.
- (26 Nov) I have posted notes from last week's
- (22 Nov) The second midterm solutions
are now up. Happy Thanksgiving -- I'll see you after the break, and I will
be reading email in the meantime.
- (22 Nov) The second midterm is now up.
I still owe you notes for Discussion #9 and solutions for the second midterm.
- (19 Nov) Notes for Discussion #8 are now up.
I also owe you notes for #9, which I will get up as soon as I can. Remember
that there are lectures but no discussion this week.
- (13 Nov) The HW#5 assignment will be up shortly.
It is due Wed 29 November. The HW#6 assignment will be due the last day of
classes, Wed 13 December.
- (13 Nov) Some scheduling notes, which I've announced in class:
- There is no class Fri 17 Nov because of a department faculty retreat.
I will also miss office hours that day, and there will be no honors class.
We are a lecture ahead of the syllabus at the
moment, so we will be back in step with it by Monday.
- There is a general CMPSCI
undergraduate meeting tomorrow (Tue 14 Nov) at 3:45 in room 151 of the CMPSCI
building. There will be brief talks by Prof. Rui Wang on graphics and by
graduate student Tom Heydt-Benjamin on RFID credit card security (work featured
in The New York Times and various TV shows). There will also be general
information for preregistration and the chance to meet with faculty advisors.
- There is no discussion next week, but there will be normal lectures on
Monday and Wednesday. I will understand if people have to miss Wednesday's
class for family obligations.
- (6 Nov) I have posted solutions to the
second practice exam. Note that the real exam will cover only chapters
5, 6, and 7 (and prior material as relevant), not the lecture material from
- (5 Nov) I will be away all day Tuesday, Election Day, and will not have
my usual office hours. Please vote if you are eligible!
- (5 Nov) Full Discussion #7 notes are now up.
I will try to get practice exam solutions up by the end of Monday.
- (3 Nov) I have posted a partial version of the notes
for Discussion #7, with all three question texts and a solution for only
the first problem. I'll note here when the rest is finished.
- (3 Nov) I have posted the practice exam for the
second midterm. I will try to have dscussion notes for Discussion #7 up by the
end of the day.
- (3 Nov) A purely
self-serving announcement: As I mentioned in lecture on Wednesday,
I am performing in the Valley Light Opera
production of The
Gondoliers at Amherst Regional High School. The five performances are
November 3, 4, 10 and 11 at 8:00 pm, and November 5 at 2:00 pm. Tickets
are $16 with $13 for students or seniors, except for tonight's opening
performance which has $5 general admission tickets for students, available at
- (26 Oct) I have posted notes for Discussion #6.
- (24 Oct) I have posted the fourth HW assignment.
- (19 Oct) I have posted notes on this week's discussion.
- (10 Oct) The third HW assignment is now posted,
due Monday 23 October. Graded HW#2 will be handed back in class tomorrow.
Robert noted to me that many students left off arguments for correctness and
timing of their algorithms on HW#2. Remember that whenever you present an
algorithm as a solution to a problem of the form "solve this problem within
this time bound", you are responsible for arguing both that your algorithm
is correct (on all cases) and meets the time bound (in the worst case).
- (10 Oct) Here are all the scores on the first midterm in order: 99, 85, 83,
81, 80, 80, 79, 77, 76, 73, 71, 71, 69, 68, 64 (median), 61, 59, 57, 56, 55, 52,
47, 45, 43, 43, 42, 41, 38, 36.
- (9 Oct) I have posted the text of the first
midterm and solutions for it. I have
graded the tests -- high was 99, second-high 85, A level 85, C level 55, low
36. There were eight people below 50 who should talk to me, though I have
every hope of all those people passing the course. You may pick up exams at
my office hours tomorrow morning, or in class Wednesday. I will post more
detailed exam information, and the third HW assignment, tomorrow morning.
- (4 Oct) I have posted notes for this week's
discussion. Note that discussions are fair game for the test, as are
all lectures through yesterday. I will post HW#3 sometime over the weekend --
it will be due in class on Monday 23 October. Also note that there is no
discussion next week because of the Columbus Day holiday -- see the
- (2 Oct) The solutions to the practice
exam are now up. Also, Robert has HW#2 solutions available on
- (28 Sept) Homework #1 has been graded and papers will be returned in
class tomorrow. The results were disappointing -- there were 27 papers
turned in with a high of 82, mean of 54, median of 51, and low of 10.
I'm going to set the scale for this one at A=80, C=45. I hope the scores will
improve -- I expect the group work will lead to some improvement.
Robert, the TA, has some requests for future homeworks:
- Please staple your homework so that solutions to the problems come in the
order that they were assigned.
- Please try to write neatly and leave spaces between different problems.
- When disproving a statement with a counterexample, provide a concrete
counterexample. It is not enough to explain how a counterexample could be
derived, unless you give a rigorous proof that your derivation will lead to
- Every statement needs to be proven explicitly, unless you are instructed
otherwise. (This "proof" may consist of quoting results from the book or from
lecture, but a statement must be justified unless we consider it obvious. Yes,
this is a subjective standard, but this is the way that mathematics works.)
- If you find mistakes I made while grading, or you would like an explanation
of one of my decisions, please visit me in my office hours or
email me to set up another time to
meet. If you still disagree after talking to me, you may appeal my decision to
- (28 Sept) I have just posted the practice
exam for Midterm #1 (which happens a week from tonight) and
notes for Discussion
#3. I do not yet have a complete solution for the second problem on
the Discussion -- I have an algorithm but not a proof that it always works.
I'll update this when I can.
- (22 Sept) I'm adjusting my office hours -- I
have acquired a regular pre-lunch meeting on Wednesdays so I am dropping my
former 11-12 office hour then. I've also had to schedule a meeting during 11-12
today, but in general I will be in 11-12 Fridays.
- (21 Sept) I have posted the text and solution for
Discussion #2. I'm sorry that the third problem wasn't very clearly
specified, but I hope that exposure to this kind of proof was useful.
- (21 Sept) Homework solutions are available
here. Because I
don't want the solutions to be readable by the world, they are
password-protected. The username is CS311STUDENT and the password will be
given out in lecture tomorrow.
- (18 Sept) Here are the ten homework groups -- I've also emailed each
group with all three members' email addresses:
- Group A: Maletz, Smith, Widmeier
- Group B: Partensky, Shah, Taylor
- Group C: Bennett, Conlonova, Kemp
- Group D: Dean, Masi, Pratt
- Group E: Baumann, Ketchekeu, Morrison
- Group F: Morgan, Shankar, Sokolova
- Group G: Olivares, Sinischalchi, Van Thong
- Group H: Chim, Farinella, Krainin
- Group I: Burov, Cook, Gaquin
- Group J: Chen, St. James, Yamkovoy
I have posted the HW#2 assignment, due in two weeks.
- (18 Sept) As I wrote on the board but forgot to announce in class, the
department is holding a "CS Saturday" event on 30 September, for junior and
senior undergrads considering graduate school in computer science (not
necessarily at UMass). The event is free but you must register by Thursday 21
September -- more information is available
- (15 Sept) I've answered the first two student
questions on HW#1.
- (14 Sept) The solutions for Discussion #1
are now complete.
- (13 Sept) I have started the discussion notes page
and put up the text and partial solutions to this week's
discussion. I'll finish the solutions as soon as I can, probably by
- (13 Sept) My office hours are 11-12 each weekday in CMPSCI building room
210. Robert's office hours are 12-1 Tuesday and Thursday in LGRT 220.
- (7 Sept) The first homework assignment is now up.
- (7 Sept) I've posted a page for course
requirements and grading which includes the academic honesty policy.
The first HW assignment, due a week from Monday, should be posted shortly.
- (1 Sept) The syllabus is now up. We also
have a TA, Robert Lychev, whose contact info is on the
- (16 Aug) Welcome to my CMPSCI 311 blog. This will be my primary means
of communicating with students in the course. I've started the web site today
and will gradually get more of the material up over the next week or two.
The first lecture will be on Wed 6 September. Note
immediately that there is no discussion meeting on the first day of
class, Wed 6 September. Discussions will start the following week, on Monday
11 September for one section and on Wednesday 13 September for the other. Many
of you just took CMPSCI 250 from me last spring -- you will find the discussion
system similar. I will assign a problem for each discussion meeting and divide
you into groups to solve the problem and give me one writeup per group. These
will be graded "no credit", "check", or "check-plus" -- note that discussion
meetings are therefore required.
There will be two midterms, on Thursday evenings (5 October and 9 November).
These divide the course into three blocks -- there will be two homework
assignments in each block. After the first assignment I will set up homework
groups -- half of the later assignments will be individual and half will be done
in groups with a single writeup.
Do you belong in this course? You should have passed CMPSCI 250 or
equivalent (discrete mathematics) and either have passed CMPSCI 287 (programming
paradigms) or be taking it this term. (Therefore you must have passed the
entire intro Java sequence, through CMPSCI 187.)
There will be no explicit programming in the
course (nothing has to compile) but the course is about algorithms and real
programming languages provide a good way of describing algorithms.
If you think you belong in the course but SPIRE will not let you add it,
talk to me either in person or by email. It may be that SPIRE is not
recognizing a valid prerequisite, or it may be that you can talk me into waiving
Last modified 15 January 2007