COS 226: Data Structures and Algorithms

Difficulty: 2/5
Semester: 2020-Fall

COS 226 is Princeton’s Data Structures and Algorithms course and is a prerequisite to being a Computer Science major at our university.

Data structures and algorithms are fundamental topics in computer science. Data structures refer to the organization of data, and commonly used structures include lists, trees, stacks, and queues. Algorithms are the step-by-step procedures for solving computational problems or performing tasks like searching, sorting, and optimization.

Should You Take COS 226?

Short answer: Yes. As a topic, Data Structures and Algorithms is not just essential knowledge for anyone in any sort of problem-based thinking, and also opens up infinite job opportunities because it is the heart of all technical software engineering job interviews. As a course, COS226 is probably the most well-organized course that I have taken at Princeton. Many other colleges use our course for the basis of this fundamental knowledge, especially with Kevin Wayne and Robert Sedgewick’s lectures on Coursera, to give you some additional context.

If you’re doing doing COS, ORF, or ECE, you’ll definitely take it. If you’re in any other technical subject (engineers, physics, etc.), you should definitely take it too.

But I didn’t like COS126…? COS 226 is a very different course than COS 126, and much better in my opinion. COS 226 is much more narrow in its scope and only focuses on the fundamentals, rather than surveying multiple seemingly random topics in Computer Science, as 126 does.

When Should You Take It?

As early as possible. If you have any experience in coding at all, I would recommend placing out of COS 126 with the placement test, or just straight enrolling in COS 226 without even doing the placement exam. You really don’t need any knowledge of COS 126 to succeed, and I know multiple people who did well having COS 226 as their first coding class in their life. Do not let someone tell you that it is too much work, I estimate each assignment took me about 4-8 hours, with some taking much less. Most of the assignments are partnered as well.


You’d be doing yourself a disservice if you don’t take this course, even if you do struggle through it. I made many friends through this course, and my Computer Science partner was great; I continued partnering with him for many courses afterwards. You also learn the ways of pair programming, which is a key skill in industry and life.

I liked this course so much that I was a preceptor for it my first and second years at Princeton. It also offers you the opportunity to develop a mentor relationship with your instructor preceptor.

The Course Structure and Resources

Textbook: Algorithms, 4th edition by Robert Sedgewick and Kevin Wayne. Addison-Wesley Professional, 2011, ISBN 0-321-57351-X. → VERY UNNECESSARY. Do not buy; do not read.

Studio-produced lecture videos. You can access studio-produced lecture videos that accompany the textbook via CUbits. → Useful, but not necessary at all.

Course website:


  1. Go to lecture. Kevin Wayne is one of the best lecturers at Princeton, and you have the opportunity to ask questions live. As someone who barely goes to lecture, I can tell you: these lectures are worth it. You actually retain the content, and the examples with animations are really helpful.
  2. YMMV but I just grinded the assignments out in one go every week on the weekend before they were do. The projects are simple enough, and don’t require much creativity, so the standard advice of piecemeal-ing a few hours at a time doesn’t really apply.
  3. Finding a good partner: (1) someone who is reliable and willing to do work (2) someone who is at similar skill level. Reliability is most important because you want someone you can depend on, for example, if you fall through or can’t work, that they can pick up the slack. Also, don’t divy up the assignments between the two of you. COS 226 is not the type of course that you can only understand part of and do well in.
  4. Learn more than the course teaches you. I would concurrently do Leetcode problems and sharpen your DSA skills while you are taking the course because this course will enable you to get internships at top tech companies easily. But relearning the material is more difficult than truly mastering it in the first place.
  5. Go to the precepts and complete all the assignments. Don’t forget about the quizzes.
  6. For the midterm, redo the previous midterms and all the quizzes, and make sure you have them on lock. For the final, the previous finals are your best bet. The first time you complete the previous midterms and finals, try to complete without looking at the solution with a timer. All the problems you cannot do, just skip. Then, at the end, write down the material that you missed, study it, then look at the solution. You should progress in the order of the oldest exam to the newest (as these will be the most relevant for your success). Make sure that you review the previous exam’s solutions before attempting the next, so you don’t continually make the same mistakes. You will start to realize that you know the content, and by the time you get to the newest exam, you shouldn’t be making mistakes. Then, do all the exams again; it should go much quicker.

For specific problems:

  • For graph based exam problems, a common trick is to duplicate graph $G$ to $G’$, which has some desired property, and then connect graph $G$ with $G’$ somehow.
  • Make a list of all the algorithms that you learned, and the runtime of all of them. Do the same with all the data structures. The book site and lecture slides have these tables for different topics; memorize them. When you get stuck, go through them one-by-one until you find the right one.

Tejas Gupta

New York City, USA
Email me

Tejas Gupta is a Princeton University student in the Department of Computer Science. He is currently studying at ETH Zürich.