Looking for last year's course web site?
Click here for the CS 106X, Autumn 2015 course web site.
NOTE: This web site is out of date.
This is the course web site from a past quarter, Autumn 2016.
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://cs106x.stanford.edu/.
If you are already at http://cs106x.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.
(Suggested book reading: Programming Abstractions in C++, section 10.2)
Today we will talk about ways to analyze the runtime of algorithms.
Many interesting algorithms process data.
We are most interested in the algorithm's runtime as the number of elements of data (which we'll call "N") grows.
Suppose we measure the runtime of three hypothetical algorithms:
Algorithm 3 is obviously much faster, but the main thing to look at is the rate of growth.
For algorithms 1 and 2, when you double the input size N, the runtime goes up by a factor of roughly 4.
For algorithm 3, when you double N, the runtime goes up by a factor of roughly 2.
This growth rate, not the absolute runtime measured on a particular run, is the most important thing to look at when analyzing and choosing algorithms.
We categorize algorithms into groups called complexity classes by looking at their growth rate relative to input size N.
Suppose you measure the runtime for a particular N value and then change N.
If you increase N and the runtime does not change, we say that the algorithm has constant runtime.
If you increase N by a factor of K and the algorithm's runtime also roughly increases by a factor of K, we say the algorithm has linear growth.
(Algorithm 3 above)
If you increase N by a factor of K and the algorithm's runtime roughly increases by a factor of K*K, we say the algorithm has quadratic growth.
(Algorithms 1, 2 above)
...
There are many different complexity classes, and as we write and analyze algorithms, we will learn ways of estimating and calculating the complexity class of a given piece of code.
In your file's comment header, list both partners' names; also cite all sources of help, including books, web pages, friends, section leaders, etc.
Do not consult any assignment solutions that are not your (pair's) own.
Do not attempt to disguise any code that is not your (pair's) own.
Do not give out your assignment solution to another student (outside of your pair).
Do not post your homework solution code online. (e.g. PasteBin, DropBox, web forums).
Please take steps to ensure that your (pair's) work is not easily copied by others.
Remember that we run similarity-detection software over all solutions,
including this quarter and past quarters, as well as any solutions we find on the web.
If you need help solving an assignment, we are happy to help you.
You can go to the LaIR,
or the course message forum,
or email your section leader,
or visit the instructor / head TA during office hours.
You can do it!