To visit the website for fall quarter's CS106B offering, click here.
Midterm Logistics
February 20, 2017

The midterm exam is tomorrow, February 21st. Exam locations are divvied up by last (family) name:

  • Abb - Lam: Go to Hewlett 200.
  • Lee - Nic: Go to Hewlett 201.
  • Ntu - Zhu: Go to Cubberly Auditorium.

As a reminder, the exam is closed-book, closed-computer, and limited-note. You can bring a single, double-sided sheet of 8.5" × 11" notes to the exam. We'll also provide you with a C++ Library Reference sheet that'll be included with the physical copy of the exam. The exam covers material up through and including the two lectures on big-O notation and sorting algorithms, along with topics from Assignments 0 - 4.

Best of luck on the exam!

Assignment 4 Released
February 6, 2017

Our four assignment, Recursion to the Rescue!, goes out today. It's due next Friday, February 17th, at the start of class.

This assignment is a four-parter consisting of applications of recursion to real-world problems (hospitals, disaster planning, DNA analysis, and presidential elections), and the unifying theme is the power of recursive backtracking. We're really excited to give this assignment out, and we hope that you have a lot of fun with it!

You are encouraged to work in pairs on this assignment. The problems here require a bit of thought, and it'll be super helpful to have someone to bounce ideas off of. You have plenty of time to complete the assignment, and we recommend that you follow the timetable given on the assignment handout, which has you complete everything with a bit of buffer time to spare.

This evening, Anton will be holding an assignment review session 7PM - 8PM in room 420-041 where he'll talk about different aspects of the assignment. As always, it's highly recommended!

Good luck!

Assignment 3 Released
January 30, 2017

Our third assignment, Recursion!, goes out today. It's due next Monday, February 6th, at the start of class.

This assignment six smaller parts, two of which are optional warm-up exercises and the remaining four of which should be submitted for credit. This is the first assignment of the quarter where you're permitted to work in pairs, so before you get started, we recommend that you read our FAQ about pair programming so that you have a better sense of our polices and how to work effectively.

This evening, Anton will be holding an assignment review session in room 420-040 from 7PM - 8PM where he'll talk about different aspects of the assignment. It's highly recommended, especially if you're feeling a bit shaky about recursion going into the assignment.

Good luck!

Assignment 2 Released
January 23, 2017

Our second assignment, Word Play, goes out today. It's due next Monday, January 30th, at the start of class.

This assignment is a two-parter. The first part, Word Ladders, asks you to write a program that bridges the gap between two words by finding a "ladder" of intermediate words. It's an exercise in breadth-first search and using the different container types strategically. The second, Evil Hangman, is an underhanded program that cheats at Hangman and usually wins. It's an excellent way to get comfortable writing large programs from scratch and to see the power of different collections classes used in different ways.

This evening, Anton will be holding an assignment review session in room 420-041 from 7PM - 8PM where he'll talk about different aspects of the assignment. Highly recommended!

Good luck!

Assignment 1 Released
January 13, 2017

The first programming assignment of the quarter, Assignment 1: Welcome to C++!, goes out today. It's due on Monday, January 23rd at the start of class (11:30AM). This assignment explores general C++ coding, strings, recursion, debugging, and the Stanford libraries. We hope you have fun with this one!

LaIR shifts will begin this Monday at 6PM (the LaIR will be closed on Sunday for the national holiday). Feel free to stop by for help! We highly recommend reading our handout about debugging strategies for advice about how to debug your programs and how to ask good questions in the LaIR.

Good luck!

Welcome to CS106B!
January 3, 2017

Welcome to CS106B! We've got an exciting quarter ahead of us and you're in for a real programming treat. Over the next ten weeks, we'll explore fundamental techniques in modeling and solving problems using a variety of programming techniques and evaluating their tradeoffs. By the time you're done with this class, you'll have a firm grasp of problem-solving techniques and will ready to start applying your skills in areas that you genuinely care about.

In the meantime, feel free to check out the course information handout and syllabus to learn more about what this class is all about, the prerequisites, and the course policies. If you have any questions in the meantime, feel free to email me at with questions. If you're wondering whether this is the right class for you, check out our handout with course placement information.

See you soon!


16: Assignment Checklist
06: Debugging Advice
03: Honor Code
02: Course Placement
01: Syllabus
00: Course Information

Section Handouts

Section Handout 6
Section Handout 5 | (solutions)
Section Handout 4 | (solutions)
Section Handout 3 | (solutions)
Section Handout 2 | (solutions)
Section Handout 1 | (solutions)

Practice Exams

Practice Midterm | (solutions)


Assignment 4: Recursion to the Rescue!

Assignment 3: Recursion!

Assignment 2: Word Play

Assignment 1: Welcome to C++!

Assignment 0: Welcome to CS106B!


Stanford C++ Library Documentation
C++ Standard Library Documentation
Setting Up Qt Creator
Blank Stanford C++ Project
Assignment Submitter
LaIR Helper Schedule
Working in Pairs
Style Guide
Midterm Reference Sheet


16: Linked Lists, Part I
  Slides | Condensed Slides | Code
15: Implementing Abstractions, Part II
  Slides | Condensed Slides | Code
14: Implementing Abstractions, Part I
  Slides | Condensed Slides | Code
13: Designing Abstractions
  Slides | Condensed Slides | Code
12: Algorithimic Analysis, Part II
  Slides | Condensed Slides
11: Algorithimic Analysis, Part I
  Slides | Condensed Slides | Code
10: Recursion, Part V
  Slides | Condensed Slides | Code
09: Recursion, Part IV
  Slides | Condensed Slides | Code
08: Recursion, Part III
  Slides | Condensed Slides | Code
07: Recursion, Part II
  Slides | Condensed Slides | Code
06: Recursion, Part I
  Slides | Condensed Slides | Code
05: Collections, Part III
  Slides | Code
04: Collections, Part II
  Slides | Code
03: Collections, Part I
  Slides | Code
02: Strings and Streams
  Slides | Code
01: Functions in C++
  Slides | Code
00: Introduction
  Slides | Code