(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.
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.
You are expected to follow the Stanford Honor Code.
If this is an assignment that allows pairs, the same rules apply to each team. For example, do not look at assignment solutions that do not belong to your team, and do not give your solution to anyone outside of your team.
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!