CmSc 250 Intro to Algorithms
Mathematical Review
- Basic algebra
(a + b)2 = a2 + 2ab + b2
(a - b)2 = a2 - 2ab + b2
a2 - b2 = (a + b)(a - b)
a/x + b/y = (ay + bx)/xy
Xn = XXX…..X , n times
X0 = 1 by definition
XaXb = X(a+b)
Xa / Xb = X(a-b) Prove that: X-n = 1 / Xn
(Xa )b = Xab
logaX is defined for a > 0, X > 0
Definition: logaX = Y ó aY = X
E.G: log28 = 3; 23 = 8
loga1 = 0 because a0 = 1
logX means log2X
lgX means log10X
lnX means logeX, where e is the natural number
loga(XY) = logaX + logaY
loga(X/Y) = logaX - logaY
loga(Xn) = nlogaX
Σ
2i = 2(N+1) - 1 can be proved by inductionΣ
Ai = (A(N+1) - 1)/(A - 1)
lim(n) = ∞, n → ∞
lim(na) = ∞, n → ∞, a > 0
lim(1/n) = 0, n → ∞
lim(1/(na) = 0, n → ∞, a > 0
lim(log(n)) = ∞, n → ∞
lim(an) = ∞, n → ∞, a > 0
lim( f(x) + g(x) ) = lim( f(x) ) + lim( g(x) )
lim( f(x)*g(x) ) = lim( f(x) )*lim( g(x) )
lim( f(x)/g(x) ) = lim( f(x) )/lim( g(x) )
lim( f(x)/g(x) ) = lim( f '(x) / g'(x) ) (L'Hopital's rule, applied when both limits are 0, or both are infinity)
Examples:
lim(n/ n2 ) = 0, n → ∞,
lim(n2 / n) = ∞, n → ∞
lim(n2 / n3 ) = 0, n → ∞,
lim(n3 / n2 ) = ∞, n → ∞
lim(n/((n+1)/2) = 2.
Derivatives:
(logan)' = (1/n) logae
(an)' = (an)ln(a)
Basic idea: To define objects, processes and properties in terms of simpler
objects,
simpler processes or properties of simpler objects/processes.
A recursive definition consists of:
Examples of recursive definitions:
Rule 1. f(0) = 1 i.e. 0! = 1
Rule 2. f(n) = n * f(n-1) i.e. n! = n * (n-1)!
Rule 1.1 F(0) = 1
Rule 1.2 F(1) = 1
Rule 2. F(k+1) = F(k) + F(k-1)
Note: Here, there are two terminating rules.We use proof by induction when our claim concerns a sequence of cases, which can be numbered. An example is the equality
S(N)
= Σ 2i = 2(N+1) - 1The cases here depend on N:
1. N = 0: S(0) = 20
2. N = 1: S(1) = 20 + 21
3. N = 2: S(2) = 20 + 21 + 22
…..
N = k: S(k) = 20 + 21 + 22 + ….. + 2k
….
Steps of proof by induction:
EXAMPLE:
Prove by induction that
S(N)
= Σ 2i = 2(N+1) - 1, for any integer N ≥ 0When substituting N=0 in the formula, we get
S(0) = Σ
2i = 2(0+1) - 1 = 2 - 1 = 1
i=0 to 0
Is this true?
Solution: By definition of S, S(0) = 20 = 1
By the formula we have: 2(0+1) - 1 = 21 - 1 = 1
Right sides are equal, hence the formula is true for N = 0
S(0) = Σ 2i = 2(0+1) - 1 = 1
i=0 to 0
We assume that S(k) is equal to 2(k+1) - 1, i.e.
S(k) = Σ 2i = 2(k+1) - 1
i=0 to k
Now we shall show that
S(k+1) = Σ 2i = 2(k+2) - 1
i=0 to k+1
We use the defining property of this particular sequence of sums: S(k+1) = S(k) + 2(k+1) and we substitute S(k) with its equal expression from our assumption.
Thus we have:S(k+1) = S(k) + 2(k+1) =
= 2(k+1) - 1 + 2(k+1) =
= 2. 2(k+1) - 1 =
= 21+(k+1) - 1 =
= 2(k+2) - 1
This completes our proof: We conclude that
S(N) = Σ 2i = 2(N+1) - 1, for any integer N ≥ 0
i=0 to N
Used when we want to prove that a statement is false.
Types of statements: a claim that refers to all members of a class.
EXAMPLE:
The statement "all odd numbers are prime" is false.
A counterexample is the number 9: it is odd and it is not prime.
Assume that the statement is false, i.e. its negation is true.
Show that the assumption implies that some known property is false -
this would be the contradiction.
EXAMPLE:
Prove that there is infinite number of primes.
Proof:
There is a prime number that is the largest one - Pk
Let P1, P2,.. Pk are all the prime numbers, ordered.
Consider the number N = P1*P2*….Pk + 1
( N is the product of all prime numbers plus one)
N is greater than Pk, and following our assumption
N is not prime.
All non-prime numbers are equally divided by some prime number
(This is a known property)
Hence N should be equally divided by at least one of P1 through Pk.
We can see that none of the prime numbers P1 through Pk divides N equally - there is a remainder of 1. This is the contradiction.
Based on the equivalence of P → Q and ~Q → ~P
In order to prove P → Q, we prove ~Q → ~P
Example: Prove that if the square of an integer is odd, then the integer is odd.
Proof: We will prove that if an integer is even, then its square even. We can do this using direct proof.
m2 = (2k)2 = 4k2 = 2.(2k2) Therefore m2 can be represented as a multiple of 2, therefore m2 is even.
We have proved that if an integer is even, its square is even. This is equivalent to: If the square of an integer is not even (i.e. it is odd) then the integer is not even (i.e. the integer is odd).
Exam-like problems
Consider the following functions:
n2, 2n, nlogn, n6 + n2, n4, n6 - n3, 4n, n, nn
Find the limit of the quotient of any two functions