CS106B: Programming Abstractions

Note: This web site is out of date. This is the course web site from a past quarter, Spring 2018. If you are a current student taking the course, this is not your class web site, and you should visit the current class web site instead at http://cs106b.stanford.edu/. If you are already at cs106b.stanford.edu, the web page may not be updated yet for the new quarter. Please be advised that courses change with each new quarter and instructor. Any information on this out-of-date page may not apply to you this quarter.

Spring 2018
Monday/Wednesday/Friday 2:30pm to 3:20pm in NVIDIA Auditorium


Course Overview
icon Piazza
Lecture Videos
icon QT Creator
icon Stanford C++ Lib
Blank Project



Thur. May 3rd

Friday, June 8th


Lecturer: Chris Gregg
Gates 191
Tue 4:45-6:15pm
Wed 4:45-6:15pm

Head TA Nick Troccoli
Gates B02
Mon 10AM-12PM


Sunday 7-9PM
Tues 8-10PM
Wed 6-7:30PM
Wed 7:30-9PM

Sign up here (free QueueStatus account required).

Tell us how we're doing with SCPD Office Hours! Fill out this survey.

For SCPD students only. All office hours in PST.


Final Exam Review Materials Posted

Thanks to everyone who came to the final exam review session! The slides have been posted at the top of the final exam review page, and the video has been uploaded to Canvas. We also have a few additional clarifications that have come up during the review session, as well as on Piazza, that we wanted to document here:

  • Sorting algorithm implementations are fair game for the exam, including code for each algorithm.
  • You do not need to know the "&" or "*" operators on pointers/variables for the final exam, where "&" is the operator that gets the address of a variable, and the "*" operator before a pointer variable dereferences it.
  • You will not need to worry about how to "overload" operators (e.g. overloading <<).
Final Exam Room Assignments

The CS106B final exam is Friday, June 8 8:30-11:30AM PST. Students will take the exam across several rooms on campus, organized by your last name below:

  • Last Names A-L: NVIDIA Auditorium
  • Last Names M-N: Huang 18
  • Last Names O-V: Gates B01
  • Last Names W-Z: Gates B03
Final Exam Announcements
We have several important announcements as we head into our last week:
  • As a reminder, the final exam is Friday, June 8 8:30-11:30AM, with the locations to be announced soon. If you need accommodations for the exam, you should have received an email from us - please contact us ASAP if you have not.
  • We will be holding a recorded final exam review session on Wednesday, June 6 7:30-9PM in STLC 111. We hope to see you there!
  • A fellow CS106B student has been working with us to plan Peer Office Hours on Thursday, June 7 1-3PM in STLC 118. Please feel free to stop by if you have any questions while studying for the final exam.
  • We will be holding LaIR and office hours for both on-campus and remote students through this Wednesday, June 6. After Wednesday, feel free to post questions on Piazza.
  • Since classes end after this Wednesday, there will not be any sections this week.
Final Exam Study Guide Released
The final exam study guide has been released. There are three practice exams, and the first practice exam is available on BlueBook.
Updated x4: Seventh Assignment: Trailblazer

For your final assignment, you will use the skills you’ve learned in this course to implement several classic graph algorithms– including breadth-first search, Dijkstra’s algorithm, and A* search – as you build your own version of Google Maps. In the course of doing so, you’ll get to see how pathfinding algorithms work in the real world. This assignment gives you lots of practice in thinking about how to represent abstract concepts like graphs and paths in software, and how to use your understanding of those abstractions to develop the code. We hope you’ll have fun and see this as a capstone to your CS106B experience!

We'll be holding the YEAH (Your Early Assignment Help) hours session on Tues. 5/29 at a time and location to be announced soon. We hope to see you there!

Update: we corrected an error in the "alternate path" explanation part of the spec where the alternate path excluding the edge B->C was listed as


instead of the correct alternate path


Update 2: we've added additional sample output for the Stanford and San Francisco maps! They can be found on the assignment page along with the rest of the sample output files.

Update 3: the YEAH slides have been uploaded to the course website, and the video has been uploaded to Canvas. Thank you to everyone who came!

Update 4: it was brought to our attention that the YEAH slides had the incorrect formula for calculating sufficient difference - we have corrected this.

Nick's Monday 5/28 OH Rescheduled
Because of the 3-day weekend, Nick will be rescheduling his Monday office hours to Thurs. 5/31 10AM-12PM, in Gates B02 (usual location). Please feel free to stop by!
Section 6 Correction
For Section #6, we've posted an updated solutions handout with corrections to the QuadTree challenge problem (some ranges and mid values were calculated incorrectly in the original solution).
Section 5 Correction
For Section #5, problem 9, a Piazza post pointed out some edge cases that are not correctly handled by the provided solution. We've updated the section handout, linked above, with a working solution.
Updated x2: Sixth Assignment: Huffman Encoding

For your sixth assignment, you'll get practice writing programs using binary trees and priority queues while building a file compression algorithm that allows the user to compress and decompress files using the standard Huffman algorithm for encoding and decoding.

We'll be holding the YEAH (Your Early Assignment Help) hours session on Fri. 5/18 11:30AM-12:20PM PST in Gates B03 (Basement). We hope to see you there!

Update 1: the YEAH slides have been posted on the assignment webpage, and the YEAH video has been uploaded to Canvas. Thanks to all who attended!

Update 2: the MyMap extension incorrectly listed the destructor's runtime as O(1) when it should be O(N).

Updated x 3: Fifth Assignment: Patient Queue

For your fifth assignment, you'll get practice using pointers, dynamically-allocated memory, and classes while writing different implementations of a priority queue. We'll be holding the YEAH (Your Early Assignment Help) hours session for this assignment on Friday, May 11 3:30-4:20PM in Skilling Auditorium (directly after lecture). We hope to see you there!

Update: YEAH materials have been posted on the assignment page. Thanks to everyone who attended!

Update 2: the spec erroneously mentioned that the toString method for the heap implementation must print out the values in sorted order. This is incorrect - like for the Vector implementation, you can print out the values in any order, and your implementation must run in O(n) time. The Linked List implementation must still print out the contents in sorted order. We sincerely apologize for the confusion!

Update 3: we have added a tip in the documentation for toString for how to take advantage of the PatientNode's << operator to easily convert it to a string.

Extra Free Late Day
Congratulations on finishing the midterm exam! As we reach the midway point of the quarter, we have decided to give everyone one extra "free late day" for a total of 3 for the quarter. This late day is provided retroactively, so if you previously took a third late day that you didn't have, then this third late day will remove that late penalty. As a reminder, late days are used "in order", so the first three late days that you take this quarter will be free.
Reduced LaIR Hours 5/3
Because of the midterm exam taking place today from 6-8PM, the LaIR will not be open from 7-9. Instead, we will have reduced hours from 9-11PM, so that we can reassign helpers on the 7-9 shift to help during another time.
Practice Midterm Submission Viewer Posted
We have created a webpage where, if you officially submitted your practice midterm answers via BlueBook, you can view them. Please visit to view your answers.
Boggle! YEAH Video Posted
A previously-recorded YEAH hours session for Boggle has been posted on Canvas, under "Beta - Lecture Videos", in the YEAH Hours folder.
UPDATED: Midterm Review Materials Posted
The video from the midterm review session is now available on Canvas. Additionally, the slides from the session are available on the midterm webpage.

UPDATED: we have also released section 4 solutions early in the "Sections" dropdown above, for students who want to review concepts (Memoization and Sorting) covered in this week's section problems. Note that classes are not on the midterm exam.
Midterm Exam Updates
The midterm exam is coming up this Thursday 5/3 6-8PM. The exam will be split into 2 locations: We will be holding a midterm review session Tuesday 5/1 7-8:30PM in 420-040. We will be going over concepts covered on the midterm, and answering any questions. The session will be recorded, and slides will be posted afterwards. We hope to see you there! As a reminder, we have also posted 2 practice exams, as well as other study materials and recommended study strategies. See the midterm webpage for more information.
Fourth Assignment: Boggle!

For your fourth assignment, you'll get practice writing programs using recursive backtracking and classes while implementing the classic word game, Boggle! Note: important material needed for this assignment, on classes, will be covered in lecture on Monday 4/30.

We'll be holding the YEAH (Your Early Assignment Help) hours session early next week. Stay tuned!

Midterm Review
Midterm review posted. See this link for the midterm review materials.
Important Announcements

We have several important announcements following today's lecture:

  1. Assignment Due Times 6PM: We have decided to change all assignment due times beginning with HW3 to be at 6PM PST instead of 12PM PST. This also means that, beginning with HW3, 1 late day is until the next class day at 6PM PST instead of 12PM PST.
  2. Midterm Scheduling: The midterm is coming up next Thursday 4/3 6-8PM. If you have significant academic or other conflict and cannot make this time, please fill out this form by Friday 4/27 and we will schedule an alternate time for you to take the exam. Additionally, if you have OAE accommodations, please email Chris and Nick with your OAE information as soon as possible so that we can schedule your accommodations.
  3. Midterm On Laptops: The midterm exam will be administered on computers using BlueBook software. If you do not have access to a laptop, or do have access but do not feel comfortable taking the exam on that laptop, please let Chris and Nick know as soon as possible.
  4. Reminder - Double-check HW Submissions: As a reminder, it is your responsibility to check that your homework submission is correct, and contains the required files for each assignment. In particular, you should not be submitting your entire project, or your .pro file. After submitting, please visit Paperless to view your submission and make sure the correct files were sent. We cannot allow resubmissions due to incorrect files being submitted.
  5. Pair Programming: when submitting as a pair, one person must submit and input their partner's SUNET ID. That partner then must confirm the pair submission request in their account on Paperless. We cannot grade your pair submission until you approve this pair request.
  6. Style Guide Updated: we have updated the style guide (under the "Tools" tab) with some notes on using recursion in your programs. Take a look!

Third Assignment: Recursion

For your third assignment, you'll get practice writing programs using recursion. This assignment consists of two programs - "Fractals", which draws recursive graphical patterns, and "Grammar Solver", which can generate random writing in the style of a specified structure.

We'll be holding the YEAH (Your Early Assignment Help) hours session later today (4/19) from 4:30PM-5:20PM in Skilling Auditorium (recording and slides available after). YEAH hours are sessions meant to help you get started on each assignment and answer questions, give you tips and tricks, and more. We hope to see you there!
Update: the materials have been posted on the assignment 3 page. Thanks to everyone who came!

Python to C++ Materials

Thanks to everyone who came to our Python to C++ session! The video has been posted to the lecture videos page, and the slides are available under the "Handouts" dropdown.

Second Assignment: Serafini

For your second assignment, you'll get practice writing programs using ADTs. This assignment consists of two programs - "Word Ladder", which generates connections between two different English words, and "Random Writer", which can generate random writing in the style of another writer.

Section/Grader Assignments

For those who submitted section preferences by 5PM on Sunday, section assignments are available starting at 5PM from the link in the Sections dropdown. SCPD students can view their graders at that link as well. If you were unable to submit the form by the 5PM Sunday deadline, the late signup form is available starting at 5PM under the "Sections" tab. As a reminder, SCPD students should sign up via the special SCPD link there instead.

If you would like to switch to a different section, you can swap by using the link in the "Sections" dropdown in the Sections dropdown. If you would like to switch into a different section to be with a requested partner, but you or your partner's sections are not available to swap into, please request a swap by filling out this form. For this form, please be sure to fill out ALL possible times you and your partner are free, not just your current section times.

The deadline for signups and swaps is Wednesday, 4/18, at 12PM. As a reminder, sections start this week!

Course Logistics Updates

We have a few important logistical notes as we enter the start of week 2:

  1. We are accepting submissions for HWs on cs198.stanford.edu/paperless. There, you can log in and drag-and-drop assingment files. Please see the specific assignment instructions for which files to submit.
  2. Sections will be finalized by tomorrow at 5PM; after that time, you may go to cs198.stanford.edu to view your assigned section. As a reminder, sections start this week! If you did not sign up for a section (or a grader, for SCPD), the late signup form will be open starting tomorrow at 5PM on cs198.stanford.edu.
  3. For the Game of Life assignment, we have updated the assignment webpage to indicate that, when prompting the user for wrapping, you should reprompt the user if they enter something other than y or n. Using the built-in getYesOrNo is acceptable.
  4. We have updated the general information handout to clarify course policies on late days (each student has 2, and they are class days), as well as policies surrounding pair programming (which will optionally be available for some future assignments).
  5. Nick has finalized his office hours schedule, and will be both in the LaIR as well as hold office hours in Gates B02 on Mondays from 10AM-12PM PST.
  6. We have added due dates for all assignments for the remainder of the quarter to the schedule page (right-most link in the navigation bar).
  7. As a helpful note, you can find the "rotateGrid" project that Chris mentioned last week (written in C++, Java, Javascript and Python) at this link.

Assignment 1 Released!

Assignment 1 has been posted. The YEAH video describing the assignment can be found on Canvas under "Beta Lecture Videos->YEAH Videos".

QT Creator Troubleshooting Session

If you have trouble setting up QT Creator, please feel free to come by our QT Creator troubleshooting session, happening on Wednesday, April 4 7-9PM in the LaIR (Tresidder first floor eating area).


Welcome to CS106B! We are looking forward to a fun quarter. Class starts Monday April 2nd at 2:30pm in NVIDIA Auditorium.

Sign Up for Piazza

This quarter CS106B is using Piazza to facilitate questions. Go to https://piazza.com/stanford/spring2018/cs106b/ to sign up. You can ask course related questions and see answers to other student questions. For personal questions please feel free to email Nick or Chris.

How to Create a Blank Project Video

See below for a short instructional video on how to create a blank project from a copy of another project.