Definition: The sigma (HTML) notation: ∑f(i) with i going from a to b.
Theorem: Assume 0<a≠1.
Then ∑ai with i going from 0 to n = (1-an+1)/(1-a).
Proof: Multiply by a and subtract.
Theorem:
∑i with i going from 1 to n = n(n+1)/2.
Proof:
Pair the 1 with the n, the 2 with the (n-1), etc.
This gives n/2 values of (n+1)s.
Recall that logba = c means that bc=a.
b is called the base and c is called the exponent.
Commonly log(n) means base 10
or (in computer science) base 2.
Almost always lg(n) means base 2 and
ln(n) means base e.
Theorem: Let a, b, and c be positive real numbers. In the following log means base 2. Though this is not needed, any base would do.
Ceiling: ⌈x⌉ is the least integer not less than x.
Examples:
⌊5⌋ = ⌈5⌉ = 5
⌊5.2⌋ = 5 and ⌈5.2⌉ = 6
⌊-5.2⌋ = -6 and ⌈-5.2⌉ = -5
Theorem (arithmetic): Let d(n), e(n), f(n), and g(n) be nonnegative real-valued functions of a nonnegative integer argument and assume d(n) is O(f(n)) and e(n) is O(g(n)). Then
1. ad(n) is O(f(n)) for any nonnegative a
2. d(n)+e(n) is O(f(n)+g(n))
3. d(n)e(n) is O(f(n)g(n))
Theorem (transitivity): Let d(n), f(n), and g(n) be nonnegative real-valued functions of a nonnegative integer argument and assume d(n) is O(f(n)) and f(n) is O(g(n)). Then d(n) is O(g(n)).
Theorem (special functions): (Only n varies)
| n | lg n | n lg n | n1.25 | n2 |
|---|---|---|---|---|
| 1 | 0 | 0 | 1 | 1 |
| 16 | 4 | 64 | 32 | 256 |
| 256 | 8 | 2,048 | 1,024 | 65,536 |
| 4,096 | 12 | 49,152 | 32,768 | 16,777,216 |
| 65,536 | 16 | 1,048,565 | 1,048,476 | 4,294,967,296 |
| 1,048,476 | 20 | 20,969,520 | 33,554,432 | 1,099,301,922,576 |
| 16,775,616 | 24 | 402,614,784 | 1,073,613,825 | 281,421,292,179,456 |
If the values in the table represented microseconds,
then a O(lg n)
algorithm may take 20 microseconds
to process 1,048,476 items,
a