(under construction)
Review of chapter 3.
polynomials:
For any polynomial p(n), multiplying n by a constant factor changes p(n) by at most a constant factor.
If your algorithm has worst-case running time bounded by a polynomial in the size of the input, that is good!
exponentials:
Exponentials with base > 1 (e.g. 2^n) grow large very fast. Exponentials with base < 1 (e.g. 2^{-n}) grow small very fast.
For any exponential function f(n) (such as 2n), if you increase n by a constant factor (say a factor of 2) how much can the function increase by?
If your algorithm takes time exponential in the size of the input, it won't be useful for solving very large problems!
logarithms:
log(n) grows quite slowly. e.g. log10(10100) is only 100.
If you increase n by a constant factor (say a factor of 2) how much does log(n) increase by?
summations: ∑i=ab f(i)
1. We try to bound the running time from above by a function of the size of the input.
For example, "to bubblesort an n-item list takes at most time proportional to n2". Here we take the number of items in the list as a measure of the input size.
"Euclid's algorithm takes at most time proportional to log(min(i,j))"? What is the size of the input? (Trick question. Generally, by the size of an input instance, we mean the number of characters it takes to write down the instance. So, the size of an integer n, in this sense is proportional to log(n).) Euclid's algorithm runs in polynomial time.
2. We usually neglect constant factors in the running time. ("the time is at most proportional to..." something.)
3. Running time is proportional to the number of basic operations made by the algorithm. What is a basic operation? Need to think about what machine has to do to support the operation. Basic arithmetic, array access, expression evaluation, etc.
Moore's law: Every few years, computers get faster by a constant factor.
If you get a computer that is faster by a constant factor than your old one, the new one can solve bigger problems than your old one. How much bigger? Depends on the algorithm: