Computer Science 226
Data Structures and Algorithms
Spring 2002

Course Information | Announcements | Assignments | Exercises | Lectures | Errata


This course material has been prepared to supplement Algorithms in C, Parts 1-5 by Robert Sedgewick. The schedule and some other information are specific to the Spring 2002 offering of our data structures course at Princeton, but much of the material may be useful to others taking and teaching similar courses.


This is where we will post any announcements or late-breaking news.

  • 5/21 SEAS is conducting a survey about whether or not to have a mural painted in the Friend Center for Engineering Education to bring some life and personality into an otherwise sterile building. A Web site has been created for polling. Please participate and encourage everyone you know to take part. The artist is a CS student.

  • 5/21 Course grades are now posted. On behalf of all the staff, we sincerely thank all of you for making this such a wonderful class to teach. We look forward to seeing you in future cs classes. Have a fun and productive summer!

  • 5/16 Final exam grades are now posted. You can pick up your exam from your preceptor. We plan to post final course grades sometime next week.

  • 5/9 We are in the process of scheduling some review sessions. Bo's is Monday 12:30-2:30 in CS 103 (note room change!); Lujo's is Sunday at 9pm in CS 402; Kevin's is Monday 8pm in CS 105. Kevin will hold office hours Thursday 3-4pm and Tuesday 2-4pm.

  • 5/9 Please check your grades and notify your preceptor if their are any discrepancies. Note that some exercises and assignments are still being graded.

  • 5/7 The Registrar has scheduled the final exam for Wednesday, May 15 at 7:30pm in McCosh 46. The final is comprehensive, but will stress material covered since the midterm. Here is some information on the final.

  • 5/7 By popular demand, we've update the archive of old exams to include finals from previous years. Keep in mind that the course content changes from semester to semester.

  • 4/20 In the directed graph exercise #3, the queue is a standard FIFO queue. (There is no such thing as a standard LIFO queue - this is called a stack.)

  • 4/19 Evnin Lecture on "Cryptography: Secret Codes, Spying and E-Commerce" by Ed Felten. Wednesday April 24, 8pm, Reynolds Auditorium. Among other things, Felten has cracked the SDMI, testified as an expert witness at the Microsoft trial, and consults the FBI on security issues. He's also a great speaker so you are encouraged to attend this nontechnical talk!

  • 4/18 There's an annoying bug in our reference solutions. It appears that we chop off the last character of one actor if the file does not end in a newline. Thanks to a few students for pointing out our blunder. -1 for us, but we won't deduct if you use our parse.c file and run into the same issue.

  • 4/16 We've slightly cleaned up some of the movie data sets. First, we removed all movies without any actors listed (although this shouldn't really cause your code any problems). Second, we replaced any '/' characters in movie titles to ' ' characters. (For next year, we'll convert the delimiter from '/' to '|', but we didn't want to disrupt your existing code.) We also removed a spurious newline at the end of input8.txt. Thanks to the sharp students who noticed these issues. If you discover any other dirt in the data files, let us know and we'll do our best to fix them. Real data is fun!

  • 4/15 There will not be an assignment due 4/25, so it's a good opportunity to catch up on your readings. The last assignment will be due 5/2.

  • 4/14 The Registrar has scheduled the final exam for Wednesday, May 15 at 7:30pm in McCosh 46.

  • 4/10 The Undirected Graph and MST exercises are due 4/15. The Directed Graph exercises are due 4/22.

  • 4/3 Lectures 17-22 cover material from Algorithms in C, Part 5, Third Edition. This book was not available in the U-store at the beginning of the semester, but it is now available.

  • 4/1 The original version of the language modeling assignment contained an error: the first line of the output for the example input should start be 5 distinct keys instead of 11 distinct keys.

  • 3/27 Sorry for running out of time in lecture before we got to LZW compression. Please refer to the online lecture notes and demo.

  • 3/18 Midterms will be returned Monday 3/25 in precept.

    3/18 Precept #2 should go to Friend 110 on Monday 3/25 at 1:30.

  • 3/18 Looking to gain programming experience over the summer in a relaxed environment and get paid for it? We encourage you (especially women and under represented minorities) to apply to the Summer Programming Experience program. If you are a more experienced programmer (especially with some knowledge of Java), come join the 126/226 Course Development Team. Visit or email Kevin if you have any questions.

  • 3/12 Assignments 5 and 6 are due Thursday 3/28 and Thursday 4/4, respectively. The Wednesday due dates in the course packet are typos.

  • 3/5 The midterm is Wednesday 3/13 in class (despite a typo on p. 4 of the course packet). Here is some information on the midterm. Here is an archive of old exams.

  • 3/5 To avoid running into quota problems on arizona with our large data files, don't copy them into your account. Instead, access them directly from /u/cs226/pub/. Also, you can use /var/tmp/ if you need to temporarily store large files.

  • 2/13 You can now access your grades online.

  • 2/7 Adventurous programmers might be interested in the Google Programming Contest.

  • 2/2 Please check which precept you are enrolled in. Note that there are two precepts that meet at 1:30. We'll post room assignments as soon as they are available. They may be different from the ones listed by the University so be sure to check back. Precept 1 (M 12:30) is currently oversubscribed and Precept 4 (M 3:30) is undersubscribed. To request a precept change (or if you are not signed up for one on our list), please see Kevin in lecture on Wednesday. This includes most high school and graduate students since the Registrar has not provided us with your info.

  • 2/2 The course packet should be available at Pequod Copy by Friday 2/8 or Monday 2/11. It contains copies of the lecture notes (also available online) and some readings from Algorithm in C, 2nd Edition. We'll hand out notes for the first lecture in class on Monday.

  • 2/2 We plan to update some of the assignments, checklists, and exercises this semester. So, if you plan to print them out, wait until one week prior to the due date.

  • 1/27 This page is an important source of information about the course that you should check regularly. To show us that you've been here, while also providing us with some helpful statistics, please fill out the COS 226 student survey.

  • 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 C to use this supplemental material in conjunction with their course.

    Copyright (c) 2002, Robert Sedgewick

    Short history of credits:   These course materials have been under development by R. 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 are being made in 2002. Problems in exams and problem sets are adapted from many sources, but primarily the new (third) edition of Algorithms in C.

    cos226 Class Page
    Last modified: January 27, 2002