Computer Science 226
Algorithms and Data Structures
Fall 2004

Course Information | Assignments | Exercises | Lectures


Description:   This course surveys the most important algorithms and data structures in use on computers today. Particular emphasis is given to algorithms for sorting, searching, and string processing. Fundamental algorithms in a number of other areas are covered as well, including geometric and graph algorithms. The course will concentrate on developing implementations, understanding their performance characteristics, and estimating their potential effectiveness in applications.

Instructor:   Robert Sedgewick, CS 319, 258-4345, rs@cs. Office hours TTh 2-3.

Lectures:   TTh 11-12:20, CS 105. Attendance at lectures is expected.

Precepts:   Precepts meet on Tuesdays for 50 minutes. At precepts, we will return and discuss the exercises and programming assignment from the previous week. We will also give details and answer questions about the new assignment. You should come prepared to participate in the discussion, not just ask questions. The first precept is 9/14. Precept scheduling information will be posted here and announced in lecture on 9/9. Here is a list of students sorted by precept and by name.

# Time Room Preceptor Office Hours Email
 1  T 12:30 Friend 005 Satyen Kale CS 313 M 2-3 satyen@cs
 2  T 3:30 Friend 005 Seshadhri Comandur CS 415 W 12-1 csesha@cs

Web Site:   The COS 226 course website is We will post announcements and administrative information on this site and use it to control assignment submission and other administrative tasks. You will find course content such as lecture notes, programming assignments, and exercises here at You may wish to bookmark this link for direct access to course materials that will persist after the end of the course.

Textbooks:   The course textbooks are:

  • Algorithms in Java, Third Edition, Parts 1-4 by Robert Sedgewick, Addison-Wesley, 2003. ISBN 0-201-36120-5.
  • Algorithms in Java, Third Edition, Part 5 by Robert Sedgewick, Addison-Wesley, 2003. ISBN 0-201-36121-3.
  • You are expected to read the books, particularly the parts that cover the same ground as lectures and programming assignments. They contain a wealth of information beyond what we can cover in lecture that are certain to enhance your understanding of the course material. A safe strategy is to skim through the book before lecture to get a general idea of what is to be covered, then study it carefully afterwards. While you are not responsible for reading about topics that we do not cover in lecture or that are beyond the scope of the course, you are responsible for exercising good judgement about choosing what to read.

    Prerequisites:   COS 126 or COS 217 or permission of instructor.

    Grades:   Your grade for the course will be based on the following components: programming assignments: (45%), exercises: (15%), midterm exam: (15%), final exam: (25%), and staff discretion.

    Programming assignments:   There will be weekly programming assignments. Generally, they will be due on Fridays at 11:59 PM.

    Exercises:   There will also be weekly exercises. These will consist of short questions on the material in the lectures. Some of these questions will reappear on the exams, but with different input data. Exercises are due at the beginning of lecture on Tuesdays and will be returned in precepts. In calculating your course grade, we will drop your lowest three exercise scores.

    Exams:   There will be an in-class midterm exam on the Thursday before break, which will cover all material up to and including the lecture on the previous Thursday. Here is a study guide for the midterm. The final exam is comprehensive, although it will stress material covered since the midterm. Here is a study guide for the final. You can also study from old exams but be warned that old courses might have covered different material and used different policies for exams. Unless prior arrangements are made, a grade of zero will be recorded for missed exams. Exams are closed book, and no calculators or other computational devices are permitted. You may bring a 8.5-by-11 sheet with handwritten notes to the exam.

    Computers:   You may develop your programs on any machine that you like: we encourage you to use your own equipment. We provide instructions for for setting up a Java programming environment under Windows, OS X, and Linux.

    Lab TA coverage:   The Princeton COS department hires undergraduate lab assistants who are available to answer general computing questions in the labs. Here is the current schedule. These people should only be asked computer-related questions (e.g. Unix, Java), not questions regarding course material or programming assignments. They can also assist you in debugging your code, assuming you have first made a reasonable effort to identify the bug and isolate the problem. If you have questions regarding the course material or programming assignments, see your preceptor or instructor.

    Important note:   Please do not publish solutions to programming assignments, exercises, and exams in a way that could compromise their utility as pedagogical tools. At Princeton, this is a violation of the basic rights, rules and responsibilities of members of the university community.

    Copyright:   All rights reserved. None of this material may be reproduced, stored in a retrieval system, or transmitted, in any form or by any means, electronic, mechanical, photocopying, recording or otherwise without prior written permission. Permission is granted to instructors who adopt Algorithms in Java to use this supplemental material in conjunction with their course.

    Short history of credits:   These course materials have been under development by Robert Sedgewick since at least 1978. The index, course information and other .html files on this website were created by Ed Felten in 1993-95, adapting the course materials written by Sedgewick in 1991. The lecture notes and most assignments were rewritten by Sedgewick in 1996-1997. Some material was added by Michael Goldwasser in 1999. Further updates by Bob Sedgewick and Kevin Wayne in 2003 and 2004. Problems in exams and problem sets are adapted from many sources, but primarily the new (third) edition of Algorithms in Java.