You are on page 1of 5

Chapter 1

Introduction
1.1: What is an Algorithm?
Al-Khowrizm is a set of rules that carry out some calculation, it can be done by hand,
calculators or computers. For example, to multiply two numbers 254 and 123 can be done by
American style, English style or la russe as given in Fig. 1.1 below:
L
R

254
254
254
123
123
123
127
246
246
-------------63
492
738
692
254
31
984
1722
+ 508
+ 508
15
1968
3690
254
762
7
3936
7626
------------------3
7872
15498
31242
31242
1
15744
31242
0
(a) American
(b) English
(c) la russe
Fig. 1.1 Different ways to multiply two numbers
la russe algorithm is given as:
Set =0
Repeat
Divide L by 2
If the remainder is 1 add R to
Multiply R by 2
Until L=0
This a la russe algorithm is more suitable for computer with divide by 2 and multiply by 2 are
shift left and and shift right instructions in machine languages
Another way, to multiply by Divide and Conquer (D&C) method: Assume that both x and y have
2k digits, and they can be divided into two parts. Let x=xLxR and y=yLyR then
x.y=xLyL.102k+(xLyR+xRyL)10k+xRyR

(1.1)

For example x=2345, and y=1372 then xL=23, xR=45, yL=13 and yR=72 and the result of x.y is:
xy= 23x13x104+(23x72=45x13)102+45x72
=3217340

It is easy to verify that xLyR+xRyL = -(xR-xL)(yR-yL)+xRyR+xLyL, therefore to multiply two 2kdigit numbers together needs only three(instead of four) times to multiply two k-digit numbers.
It turns out that multiply two n-digits numbers needs 3lg n n lg 3 multiplications, instead of n 2
multiplications, between digit and digit.

1.2 Some Mathematical Notations


: For all
: There exists
!: There exists exactly one

: For all except some

n N n0 N , n N , n n0

: There are infinite numbers

1.3 Proof by Contradiction


This is an indirect proof, that assume the conclusion is incorrect then it will lead to a
contradiction, then this means that the assumption is incorrect or the conclusion is correct. Some
examples of using this method are given below
1.3.1 There are infinitely many prime numbers
Proof by contradiction: Assume that the above statement is incorrect, it means that the set of
prime number is a finite set P. P is not empty because 2 P. Since P is finite then define x as
the product of all elements in P. Now let y=x+1, y is larger than the largest number in P,
therefore y is not a prime number. Then there exists a smallest prime divisor d of y, and d
differs from 1. d P , therefore d is also a divisor of x. This means d is a divisor of 1, and
d>1. This is impossible, and it is a contradiction, therefore the assumption (the number of
prime is finite) is not correct .
1.3.2 There exists two irrational number x and y such that xy is rational
Proof by contradiction: Assume that xy is irrational for all irrational numbers x,y. Now, let x=
( 2)

and y= 2 , then xy=2, a contradiction

1.4 Mathematical Induction


Induction vs. Deduction
Induction is inferring a general law from particular instances
Deduction is inferring from the general law to a particular instance
1.4.1: Induction proof:

Prove that

i
i 1

n(n 1)
2

(1.2)

Induction proof normally has 2 steps: (a) Basic step: Verify the equation for some small n (b)
Induction step: Assume that the property is true upto n-1 then we need to prove it is also true for
n.
Recall back to the problem given in (1.2)
a) Basic Step: Verify (1.2) for n=1: LHS=1 and RHS=

1(1 1)
1 , equation 1.2 is correct for
2

n=1.
b) Induction step: Assume that the formula is true upto n-1 then we need to prove it is also true
for n
by .assumption

n
n 1
(n 1)n
(n 1 2)n n(n 1)

1 i 1 i n 2 n
2
2
1.4.2 Constructive Induction
The fibonnaci sequence is defined as
Fib(0)=0
Fib(1)=1
Fib(n)=Fib(n-1)+Fib(n-2).

We want to show that (x 1) n N that Fib(n) xn


In this case there are two unknown values, what is the value of x? and how large of n this
property is true (Fib(n) xn)?
Assume that n large enough, therefore Fib(n-1), Fib(n-2) and Fib(n) all satisfies the property. We
have:
Fib(n)=Fib(n-1)+Fib(n-2)
xn-1+xn-2
=(x-1+x-2)xn
xn
1 5
.
This can be true if =(x-1+x-2) 1 or x2-x-1 0 . This implies 1<x

1.5 Some Reminders


1.5.1 Arithmetic Series
n 1

a id na 2 (n 1)d
i 0

1.5.2 Geometric Series


n 1

ar

1 r .
a
n

1 r

i 0

This sum will be converged to

a
if r <1.
1 r

1.5.3 Permutation:
Permutation of n objects is an ordered arrangement of these objects. First object can be any
object (n different ways to be selected), then the second object should be differed from the first
object, it means that there are n-1 ways to select the second object . Therefore there are n!
permutations of n objects
n

n!=n(n-1)(n-2).1= i

(1.3)

i 1

There are 6 ways to arrange three objects a,b,c. They are abc, acb, bac, bca, cab, cba.

1.5.4 Combination
Combination of r objects from n objects is a selection of r objects without regarding to the
n
order of selection. The number of combinations denoted as C rn or and equal to
r
n
n!
n
(1.4)
C r r r!(n r )!
It is easy to see that
n
n 1
n 1
(1.5)
C r C r 1 C r
Equation 1.5 can be proved by two ways
(1) Use (1.4) to balance two sides of (1.5).
(2) Let consider all combination to select r objects from n objects with and without a special
object, let say object 1. In the first case, we need to select another r-1 from n-1 remaining
n 1
n 1
objects ( C r 1 ). In the second case, we need to select r objects from n-1 objects ( C r ).
Moreover we can derive

n
r

n 1
r

n2
r

n 1

n 1

C r 1 C r
n2

n2

n 3

n 3

C r 1 C r

C r 1 C r

r 1

r 1

C C

r 1

Cr

Summation both two sides and noted that C rr 1 0 , we get


C rn

n 1

k r 1

k
r 1

(1.6)

You might also like