CS 161 Piazza Textbook



Sign up for Piazza here

  • We will try to answer questions in a timely fashion; but be aware that we have to sleep too. (Do NOT count on Piazza for last-minute homework help!!!)
  • You can answer your peers' questions! That would be awesome!


Main textbook: CLRS.

  • Thomas H. Cormen, Charles E. Leiserson, Ronald L. Rivest, Clifford Stein, Introduction to Algorithms, 3rd Edition, MIT Press.
  • This book is available online for free through the stanford library.

You might also find the following textbooks to be helpful references:

  • Jon Kleinberg, Éva Tardos: Algorithm Design
  • Sanjoy Dasgupta, Christos Papadimitriou, Umesh Vazirani: Algorithms
  • Tim Roughgarden: Algorithms Illuminated. This great series of books also has many resources that go along with it that you might find helpful, including video lectures; you can find those here.

LaTeX Resources

We strongly recommend typesetting solutions to homework sets in LaTeX. LaTeX is the standard for typesetting CS/math/etc papers, and will likely come in handy outside CS161.

  • Example LaTeX solution set: See the Homework Resources section below for an example of a LaTeX'd solution set and a LaTeX template. These solutions include examples of pseudocode in a few different environments, as well as examples of how to include images and figures.
  • Guides to using LaTeX: An introduction to LaTeX can be found here. Other guides can be found at Wikibooks and NYU.
  • Online Environments: If you don't want to install LaTeX, ShareLaTeX and Overleaf are online environments which compile previews of your LaTeX documents as you type. (They also allow you to share your LaTeX with others; but of course you won't be needing that feature for this class!) Stanford students get a free OverLeaf Pro account.
  • LaTeX Editors: There are many LaTeX editors which allow you to use GUI to edit your LaTeX. LyX is a free one.
  • Finding symbols: Detexify lets you draw the symbol that you are looking for and get LaTeX code. A static guide is here.

Python Resources

We'll be using a little bit of Python in CS161. It won't be too intense, but here are some resources to help you get familiar with Python if you haven't seen it before.

  • Python 2 vs. Python 3. All examples and homework files in this class will be using Python 3 , which differs from Python 2 in a few important ways. (For example, integer division works differently). Here is a list of differences between Python 2 and Python 3.
  • Documentation: Python documentation is here.
  • Tutorials: A good tutorial for Python can be found here
  • In-line help: In the prompt in the Jupyter Notebook, if you type "help(x)" it will display a help page for x.
  • Jupyter: The pre-class exercise for Lecture 2 gives some info about how to install Jupyter with Python 3. tl;dr: Here is the Jupyter documentation, which tells you how to install Jupyter notebooks. Please install Python 3.
  • Have Python resources that you like? Let us know and we'll add them here!

Homework Resources

  • Guidelines: One of the big skills you'll be developing in CS161 is how to communicate technical material clearly. To that end, we expect homework sets in CS161 to be clear, and easily human-readable. Think of them like memos you might write to a colleague. Better still, think of them as memos that you might write for a team of colleagues, who may be working quickly and also who have control over your grade.

    Your homeworks should be typed and clearly written with complete sentences and well-organized logic, and should definitely not be your first draft.

    When we ask for pseudocode, we are expecting pseudocode that is clear enough that a CS106B student (and certainly the grader) can understand what your algorithm is doing, and could implement it in a language of their choice, without thinking too hard. It is good practice to include an English description of what your pseudocode is doing, to help out the reader. See the example homework before for good and bad examples of pseudocode.

  • Example HW: To help you get an idea of what we are expecting, here is an example of an appropriate solution to a CS161 homework set (a zip file that contains the PDF and LaTeX source, along with the files for the original problem set.)
  • HW Tips:
    • Look at the example above for style advice.
    • Try to put yourself in the position of the reader. If you hadn't just been thinking about this problem for two hours, would your answer make sense to you?
    • The homework questions will always end with a text block explaining what sort of answer we expect. Read this text block carefully.
    • Start the homework early.
    • Try to "finish" the homework early, step away from it for a day, and then come back to it and read it over again. Chances are, you'll find some way to write what you've written more clearly.
    • If you get stuck, then ask for help from the course staff: come to office hours prepared to explain what you have tried, and why you are stuck.
  • Homework Template: If you don't want the full-blown example homework above, here's a bare-bones LaTeX template you can use. We will also post the PSET source code so you can borrow LaTeX code from the problem statements.

SCPD Resources

  • Reyna's section on Thursday afternoons will be recorded and you can access the videos wherever you access the lecture videos.
  • Maxime will be holding online office hours via Zoom. Please see here for the schedule. To connect to online office hours, follow these instructions:
    • 1) Create a Zoom meeting
      • go to Zoom's website here
      • click on "Launch Zoom"
      • click on "Host a meeting"
      • a pop-up window might open: click on "Open zoom.us"
      • another pop-up window might open: click on "Join audio conference by computer"
      • your Zoom meeting has been created, and a Zoom meeting window should appear
    • 2) Get the invitation URL of your Zoom meeting
      • - in your Zoom meeting window, click on "Invite"
      • - click on "Copy URL"
    • 3) Go to Queue Status' website here
    • 4) Add your name and the invitation URL of your Zoom meeting on Queue Status. Please also provide a very short description of your question (e.g. "HW3 problem 3 (a)" or "Lecture 2 Big-O notation").
    • 5) Wait in line, until it is your turn. When it is your turn, at CA will join your Zoom meeting!
  • For any issues with SCPD, please email cs161-win1819-staff@lists.stanford.edu.

Other Resources

If you need a pick-me-up.