CS 170
Efficient Algorithms and Intractable Problems
a.k.a. Introduction to CS Theory

Prof. David Wagner
Spring 2003
Tuesdays and Thursdays, 3:30-5:00 p.m.
100 Lewis


Homework Sets and Exams

All homeworks are due Thursdays at 3:30 p.m. in 283 Soda unless otherwise stated. There is a drop box labeled "CS 170". Out of a total of 12 homework assignments, the lowest two scores will be dropped. No late homeworks are accepted.


Required Readings

Grading Summary

Course Information


Whereas CS 61B was a bare introduction to the theory of computer science, CS 170 is a full exploration of it. The following is a list of lectures and approximately corresponding reading material. All dates and topics are tentative. Lecture notes may be updated, in which case they will be marked clearly. In general, there will be changes as the semester progresses, so check here periodically. Midterm dates may also change.

Topic Readings
1 January 21 Overview Notes [ps] [pdf].
CLR Chapters 1, 2, 10.1; or CLRS Chapters 1, 2, 3 and Section 9.1.
2January 23 Divide-and-Conquer; Recurrences Notes [ps] [pdf].
CLR Chapters 3 and 4; or CLRS Chapter 4 and Appendix A.
3January 28 Graphs and Trees Notes [ps] [pdf].
CLR Sections 5.4--5.5 and 23.1; or CLRS Section 22.1 and Appendix B.4--B.5.
4January 30 Depth-First Search Notes [ps] [pdf].
CLR Section 23.3; or CLRS Sections 22.3.
February 4 Topological Sorting (see notes from previous lecture)
CLR Section 23.4; or CLRS Section 22.4.
5February 6 Strongly Connected Components Notes [ps] [pdf].
CLR Section 23.5; or CLRS Section 22.5.
6February 11 Breadth-First Search Notes [ps] [pdf].
CLR Section 23.2; or CLRS Section 22.2.
7February 13 Shortest Paths: Dijkstra's Algorithm Notes [ps] [pdf].
CLR Sections 25.1-25.2; or CLRS Sections 24.3 and 24.5.
February 18 Shortest Paths: Bellman-Ford (see notes from previous lecture)
CLR Sections 25.3-25.4; or CLRS Sections 24.1-24.2.
8February 20 Minimum Spanning Trees Notes [ps] [pdf].
CLR Chapter 24; or CLRS Chapter 23.
9February 25 Hashing; Randomization Notes [ps] [pdf]. (updated 2/27)
CLR Chapter 6 and Sections 12.1-3; or CLRS Chapter 5 and Sections 11.1-3.
10February 27 Bloom Filters Notes [ps] [pdf].
11March 4 Randomized Min-Cut Notes [ps] [pdf].
March 6 Midterm I  
12March 11 Disjoint Sets; Amortization Notes [ps] [pdf].
CLR Chapter 22; or CLRS Chapter 21.
13March 13 Dynamic Programming I Notes [ps] [pdf].
CLR Chapter 16; or CLRS Chapter 15.
14March 18 Dynamic Programming II Notes [ps] [pdf].
CLR Section 26.2; or CLRS Section 25.2.
March 20 Dynamic Programming II (see notes from previous lecture)
March 25 No lecture; spring break  
March 27 No lecture; spring break  
15April 1 Horn Clauses Notes [ps] [pdf]. (added 3/29)
16April 3 Huffman Codes Notes [ps] [pdf].
CLR Section 17.3; or CLRS Section 16.3.
17April 8 Lempel-Ziv Codes; Information Theory Notes [ps] [pdf].
April 10 Midterm II  
18April 15 Optimization; Linear Programming; Simplex Notes [ps] [pdf].
CLRS Sections 29.1-29.2.
19April 17 Network Flows Notes [ps] [pdf].
CLR Sections 27.1-27.2; or CLRS Sections 26.1-26.2.
20April 22 Matching Notes [ps] [pdf].
CLR Section 27.3; or CLRS Section 26.3.
21April 24 NP-Completeness Notes [ps] [pdf].
CLR Sections 36.1-36.2; or CLRS Sections 34.1-34.2.
22April 29 Satisfiability Notes [ps] [pdf].
CLR Sections 36.3-36.4; or CLRS Sections 34.3-34.4.
23May 1 Reductions Notes [ps] [pdf].
CLR Section 36.5; or CLRS Section 34.5.
24May 6 Approximation Algorithms Notes [ps] [pdf].
CLR Sections 37.1-37.3; or CLRS Sections 35.1-35.3.
May 8 Finite-State Machines; Juggling No notes. (updated 5/8)
You're not responsible for this material.  
May 13 Review  

Discussion Sections

Contact Information

If you have a question, your best option is to post a message to the ucb.class.cs170 newsgroup. The staff (instructor and TAs) will check the newsgroup regularly, and if you use the newsgroup, other students will be able to help you too. When using the newsgroup, please avoid off-topic discussions, and please do not post answers to homework questions before the homework is due.

If your question is personal or not of interest to other students, you may send email to cs170@cory.eecs.berkeley.edu. Email to cs170@cory is forwarded to the instructor and all TAs. We prefer that you use the cs170@cory address, rather than emailing directly the instructor and/or your TA. If you wish to talk with one of us individually, you are welcome to come to our office hours. If the office hours are not convenient, you may make an appointment with any of us by email. There are about 50 of you to every one of us, so please reserve email for the questions you can't get answered in office hours, in discussion sections, or through the newsgroup.

The instructor and TAs will post announcements, clarifications, hints, etc. to this website and to the class newsgroup. Hence you should read the newsgroup regularly whether you post questions to it or not. If you've never done this before, there is online information about how to access UCB newsgroups (see also here for more).

In a class this large, it can be challenging for the instructor to gauge how smoothly the class is going. We always welcome any feedback on what we could be doing better. If you would like to send anonymous comments or criticisms, please feel free to use an anonymous remailer to send us email without revealing your identity, like this one.

Staff Office Hours and Addresses

  • Hao Chen
    Thu 11:30-12:30pm, Fri 11-12pm in 551 Soda.

  • Rob Johnson
    Mon 10-12pm, Tue 2:30-3:30pm in 511 Soda.

  • Naveen Sastry
    Tue 1-2pm, Thu 5:15-6:15pm in 751 Soda.

  • Jason Waddle
    Tue 5-6pm (651 Soda), Wed 4-6pm (551 Soda).

Course Policies

Prerequisites and Enrollment

All enrollment is handled by the CS office in 390 Soda. The prerequisites for CS 170 are CS 61B and one of Mathematics 55 or CS 70. If you have not satisfied all prerequisites, but you have taken a course you feel is very similar to CS 61B or Math 55, or if you are on a wait list, fill out an appeal form and turn it in to 390 Soda Hall by Friday, Jan 24th at 5pm. The instructor does not handle appeals, so please do not attempt to lobby him for admission to the course. The department has a FAQ on enrollment, and further information is available as well.

If you are something other than a regular Berkeley undergraduate, then you probably need a signature on a form admitting you to the course. We cannot promise to admit those of you who are not regular Berkeley students. In particular, we will not sign any concurrent enrollment or UC Extension forms until after the second week of classes.

You should be comfortable with mathematical induction, big-O notation, sorting algorithms, basic data structures, and binary heaps. In particular, if you are a transfer student and have not obtained a thorough understanding of binary heaps from CS 61B or a similar course, you should read Chapter 7 of CLR (Chapter 6 of CLRS) in preparation for this course.

You will be required to do a programming exercise in this course. You should have prior experience with C, C++, Java, Scheme, or some other comparable programming language.

If you are not familiar with the Unix operating system and basic tools, it is important that you learn. Some student groups, including CSUA, teach help sessions on Unix. See the CSUA Web pages.

CS and EECS majors should already have named accounts for the lab machines from Instructional Facilities. Lab machines may be found in 2nd floor Soda. If you do not already have an instructional account, go to a Unix machine in 273 Soda and login as 'newacct' (password: 'newacct'). You should receive a 'named' account. You can also read the online instructions. You'll need this for the programming assignment, so don't wait till the last minute.

Discussion Sections

In addition to the lectures, you should attend a discussion section for one hour each week. The discussions sections are not mandatory, and nothing done in section will directly affect your grade. On the other hand, the discussion sections are your best opportunity to ask questions and learn interactively, and some examples worked out in section will be helpful on the graded assignments. Your section TA will also return and discuss your homeworks and midterms.

Make sure that you are enrolled in a discussion section that has space for you. To find a section that has space, see the online class schedule for discussion section enrollment levels. You may attend a section other than that for which you are registered only if the TA of the section you are attending agrees to it. Outside of your discussion section, you should feel free to attend any of the staff office hours (not just your section TA's) and ask any of us for help.

Homework Assignments

A problem set is handed out each Tuesday and is due at 3:30 p.m. on the following Tuesday. Most homeworks require mathematical problem solving (algorithm design and analysis), but there is likely to be at least one programming assignment. You should turn in your problem sets in 283 Soda; there is a drop box for CS 170 that will be emptied at 3:30 p.m. every Tuesday. Late homeworks are not accepted.

Everything you turn in must be written legibly and contain your name, your discussion section number, the homework number, and "CS 170--Spring 2003". You might receive no credit for assignments that are turned in without this information. We do not attempt to grade messy and unreadable solutions. If a problem can be interpreted in more than one way, clearly state the assumptions under which you solve the problem.

In writing up your homework you are allowed to consult any book, paper, or published material. If you do so, you are required to cite the complete bibliographical data of your source(s). Simply copying a proof is not sufficient; you are expected to write it up in your own words, and you must be able to explain it if you are asked to do so. Your proofs may refer to previous course material and to previous homeworks. Except for this, all results you use must be proved explicitly.

You are allowed--even encouraged--to form small groups and work collaboratively with other students in your group on homework assignments. In such a case, you must write up the solution on your own, but you are allowed to discuss approaches to the problem with your group. Please read the section on Academic Integrity carefully for requirements on working in groups. I believe that these restrictions will not be onerous. There is no requirement that you work with the same group each time; indeed, you can do all your homework individually, if you prefer. However, if you haven't worked together in small groups on problems like this, I encourage you to give it a try: you may learn more, and many find it more fun than working by yourself.

Our goal is to get across a maximum amount of understanding in a minimum amount of time. Since you have other courses, we will try to monitor the time you spend on this course. It is easy, however, to misjudge the time required to solve a problem, so we ask you to indicate with each problem set how much time you spent completing the assignment. This is optional, and will not affect your grade. Roughly, you are expected to spend one hour reading and two hours problem solving for every hour of lecture.

Model solutions to the problem sets are handed out and discussed during the discussion sections in the week after a homework is due. The graded problem sets are returned at the same time. Graded problem sets that are not picked up in the discussion section will be kept by your section TA.

It is extremely important that you continuously stay on top of the material, because every new topic and every new homework builds on previous results. If you don't understand the material at the beginning, it will be difficult to catch up later. If you encounter problems, you are encouraged to talk to the course staff as soon as possible. Please do not wait until the last moment to do your homework--start thinking about the problems on the day they are handed out!


There will be two in-class midterm exams during the normal lecture time. They have not yet been scheduled. The final exam will take place during the regularly scheduled exam period on May 23 from 12:30 to 3:30 p.m. You must be in town for the final exam to receive a grade different from F for the class.

The midterms will be cumulative, but they will concentrate on new material. The final exam will be comprehensive.

If you miss the final exam, you will receive a grade of F in the class unless you miss it because of a circumstance beyond your control, documented by a physician or equivalent authority, or if it conflicts with another scheduled University of California exam. If we decide to forgive your missing the final exam, you will receive an Incomplete grade and have the opportunity to make it up when we choose to give you an alternate exam, quite possibly at the end of the following semester. A course grade of Incomplete will be granted only for dire medical or personal emergencies that cause you to miss the final, and only if your work up to that point has been satisfactory.

If you miss a midterm, you risk receiving a 0 on that midterm, unless you miss it because of a circumstance beyond your control or unless you gain permission in advance from the instructor. (If anyone misses a midterm, we may decide at our discretion whether to give a zero, or a percentage score based on the final exam, on that midterm.) There will be no make-up midterms.


Your final grade will be based on the weighted average of your problem set, midterm, and final exam scores. Your lowest two homework scores will be dropped. Assignments that you do not turn in will receive a zero; thus, you may skip handing in two homeworks, and then these homeworks will be the two dropped. As stated above, the homework will count for 40% of the final grade, the two midterms will each count for 15%, and the final exam will count for 30%.

We will give no credit for written homework turned in after the deadline, so that we can make on-line solutions available promptly and so that you can discuss those solutions in your discussion sections. Please do not ask for extensions for homework, even in case of emergencies; excuses for late or missed homeworks will not be accepted. The two lowest homework grades are dropped, so you can safely miss two. However, the material in this class can only be learned by doing lots of problems, so the homework is very important.

If you believe we have misgraded a homework or midterm exam question, return it to your section TA with a written note on a separate piece of paper explaining the problem. If you're requesting regrade, please staple this paper to the front of the homework or exam. The entire homework or exam will be regraded, so be sure to check the solutions to confirm that your final grade will go up after regrading. All requests for regrades and recording corrections must be made within one week after you receive the graded assignment or exam. By University policy, final exams must not be regraded.

Because of the difficulty of evaluating students in a course where much of the homework is based on proofs, the grading scale (conversion of scores to letter grades) will not be established until the end of the semester.

Academic Integrity

The work you submit in this course must be the result of your individual effort. Penalties for cheating on a homework will be assigned at our discretion, but likely will earn you an F in the class. The penalty for cheating on an exam will be receiving an F in the class (at the least). All incidents of cheating will be reported to the Office of Student Conduct, who will maintain records of your academic misconduct throughout your undergraduate career.

For homework assignments, you are allowed to work in small groups. However, there are several guidelines you must follow. You may discuss the problems within your group. However, you must write up the solution entirely on your own. In no case should you share any part of your write-up with anyone else, nor should you read nor possess any part of anyone else's write-up at any time. The written solution you hand in must list at the top the names of everyone in your group; this will not affect your grade, but it must not be omitted.

We believe that most students can distinguish between helping other students and cheating. Explaining the meaning of a question, discussing a way of approaching a solution, or collaboratively exploring how to solve a problem within your group is an interaction that we encourage. On the other hand, you should never read another student's solution or partial solution, nor have it in your possession, either electronically or on paper. You should write your homework solution strictly by yourself. You must explicitly acknowledge everyone who you have worked with or who has given you any significant ideas about the homework. Not only is this good scholarly conduct, it also protects you from accusations of theft of your colleagues' ideas.

Presenting another person's work as your own constitutes cheating, whether that person is a friend, an unknown student in this class or a previous semester's class, a solution set from a previous semester of this course, or an anonymous person on the Web who happens to have solved the problem you've been asked to solve. Everything you turn in must be your own doing, and it is your responsibility to make it clear to the graders that it really is your own work. The following activities are specifically forbidden in all graded course work:

Academic dishonesty has no place in a university; it wastes our time and yours, and it is unfair to the majority of students.

In our experience, nobody begins the semester with the intention of cheating. Students who cheat do so because they fall behind gradually and then panic. Some students get into this situation because they are afraid of an unpleasant conversation with a professor if they admit to not understanding something. We would much rather deal with your misunderstanding early than deal with its consequences later. Even if you are convinced that you are the only person in the class that doesn't understand the material, and that it is entirely your fault for having fallen behind, please overcome your feeling of guilt and ask for help as soon as you need it. Remember that the other students in the class are working under similar constraints--they are taking multiple classes and are often holding down outside employment. Don't hesitate to ask us for help--helping you learn the material is what we're paid to do, after all!

Mail inquiries to cs170@cory.eecs.berkeley.edu.
Last modified by daw on January 19, 2003.