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

Prof. Michael Jordan
Fall 2005
Monday, Wednesday and Friday, 3:00-4:00 p.m.
2050 Valley LSB



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 topics and approximately corresponding reading material. All topics are tentative.

Topic Readings
1 Overview Notes [ps] [pdf]
CLRS Chapters 1, 2, 3 and Section 9.1.
2 Divide-and-Conquer; Recurrences Notes [ps] [pdf]
CLRS Chapter 4 and Appendix A.
3 Graphs and Trees Notes [ps] [pdf]
CLRS Section 22.1 and Appendix B.4--B.5.
4 Depth-First Search Notes [ps] [pdf]
CLRS Sections 22.3.
5 Strongly Connected Components Notes [ps] [pdf]
CLRS Sections 22.5.
6 Breadth-First Search Notes [ps] [pdf]
CLRS Section 22.2.
7 Shortest Paths: Dijkstra and Bellman-Ford Notes [ps] [pdf]
CLRS Sections 24.1, 24.3, and 24.5
8 Minimum Spanning Trees Notes [ps] [pdf]
CLRS Chapter 23
9 Union/Find Notes [ps] [pdf]
CLRS Chapter 21
10 Huffman Codes Notes [ps] [pdf]
CLRS Chapter 16.3
11 Lempel-Ziv Codes Notes [ps] [pdf]
12 Randomized Min-Cut Notes [ps] [pdf]
CLRS Chapter 5 and Appendices C.2 and C.3.
13 Hashing Notes [ps] [pdf]
CLRS Chapter 11.
14 Bloom Filters Notes [ps] [pdf]
15 Dynamic Programming I Notes [ps] [pdf]
CLRS Chapter 15.
16 Dynamic Programming II Notes [ps] [pdf]
CLRS Chapter 15.
17 Linear Programming and Duality Notes [ps] [pdf]
CLRS Chapter 29.
18 Network Flows Notes [ps] [pdf]
CLRS Sections 26.1, 26.2 and 26.3.
19 NP-Completeness Notes [ps] [pdf]
CLRS Sections 34.1, 34.2, 34.3 and 34.4.
20 Approximation Algorithms Notes [ps] [pdf]
CLRS Chapter 35.
21 Fast Fourier Transform Notes [ps] [pdf]
CLRS Chapter 30.

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.

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

  • Yozo Hida
    Monday 11-12, Thursday 9-10 in 511 Soda (5th floor alcove).

  • Yan Huang
    Tuesday 5-6 in 511 Soda (5th floor alcove).

  • Junming Yin
    Wednesday 10-11, Friday 11-12 in 511 Soda (5th floor alcove).

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, September 2nd 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.

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 Wednesday and is due at 3:30 p.m. on the following Thursday. 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 Thursday. 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--Fall 2005". 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. 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 30% of the final grade, the two midterms will each count for 20%, 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 jordan on August 29, 2005.