CS 161 Piazza Textbook

Resources

Piazza

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!

Textbooks

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.

We will also occasionally point to:

  • Jon Kleinberg, Éva Tardos, Algorithm Design, Pearson/Addison-Wesley
  • Sanjoy Dasgupta, Christos Papadimitriou, Umesh Vazirani, Algorithms, McGraw-Hill Education

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. 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.

Other Resources

Handout on proof techniques.

If you need a pick-me-up.