bct 2083 discrete structure and applications chapter 2 advance counting technique siti zanariah...
TRANSCRIPT
![Page 1: BCT 2083 DISCRETE STRUCTURE AND APPLICATIONS CHAPTER 2 ADVANCE COUNTING TECHNIQUE SITI ZANARIAH SATARI FSTI/FSKKP UMP I1011](https://reader036.vdocuments.site/reader036/viewer/2022062313/56649c7d5503460f9493309a/html5/thumbnails/1.jpg)
BCT 2083 DISCRETE STRUCTURE AND APPLICATIONSBCT 2083 DISCRETE STRUCTURE AND APPLICATIONS
CHAPTER 2CHAPTER 2ADVANCE COUNTING TECHNIQUEADVANCE COUNTING TECHNIQUE
SITI ZANARIAH SATARISITI ZANARIAH SATARI
FSTI/FSKKP UMP I1011FSTI/FSKKP UMP I1011
![Page 2: BCT 2083 DISCRETE STRUCTURE AND APPLICATIONS CHAPTER 2 ADVANCE COUNTING TECHNIQUE SITI ZANARIAH SATARI FSTI/FSKKP UMP I1011](https://reader036.vdocuments.site/reader036/viewer/2022062313/56649c7d5503460f9493309a/html5/thumbnails/2.jpg)
CHAPTER 2 AD
VANCE CO
UN
TING
TECHN
IQU
E
CONTENTCONTENT
2.1 Recurrence Relations2.2 Solving Recurrence Relations2.3 Divide-and-Conquer
Relations2.4 Generating Functions2.5 Inclusion-Exclusion2.6 Application of
Inclusion-Exclusion
![Page 3: BCT 2083 DISCRETE STRUCTURE AND APPLICATIONS CHAPTER 2 ADVANCE COUNTING TECHNIQUE SITI ZANARIAH SATARI FSTI/FSKKP UMP I1011](https://reader036.vdocuments.site/reader036/viewer/2022062313/56649c7d5503460f9493309a/html5/thumbnails/3.jpg)
CHAPTER 2 AD
VANCE CO
UN
TING
TECHN
IQU
E
– Product rule
– Sum rule
– The Inclusion-Exclusion Principle
– Tree Diagrams
– The Pigeonhole Principle
– Permutations
– Combinations
1 2 1 2 1 2A A A A A A
RECALL – Counting technique RECALL – Counting technique
Number of ways = n1n2 ··· nm
Number of ways = n1 + n2 +…+ nm
If N objects are placed into k boxes, then there is at least one box
containing at least objects.N k
!
, 1 2 1!
nP n r n n n n r
n r
!
,! !
n nC n r
r r n r
![Page 4: BCT 2083 DISCRETE STRUCTURE AND APPLICATIONS CHAPTER 2 ADVANCE COUNTING TECHNIQUE SITI ZANARIAH SATARI FSTI/FSKKP UMP I1011](https://reader036.vdocuments.site/reader036/viewer/2022062313/56649c7d5503460f9493309a/html5/thumbnails/4.jpg)
2.1 RECURRENCE RELATIONS2.1 RECURRENCE RELATIONS
• Define and develop a recurrence relation
• Model a problem using recurrence relation
• Find the solution of recurrence relations
with the given initial conditions
CHAPTER 2 AD
VANCE CO
UN
TING
TECHN
IQU
E
![Page 5: BCT 2083 DISCRETE STRUCTURE AND APPLICATIONS CHAPTER 2 ADVANCE COUNTING TECHNIQUE SITI ZANARIAH SATARI FSTI/FSKKP UMP I1011](https://reader036.vdocuments.site/reader036/viewer/2022062313/56649c7d5503460f9493309a/html5/thumbnails/5.jpg)
2.1 RECURREN
CE RELATION
The number of bacteria in a colony doubles every hour. If the colony begins with 5 bacteria, how many will be present in n hours?
Let an : the number of bacteria at the end of n hoursThen;
an = 2an-1, a0=5
What we are doing actually?
We find a formula/model for an (the relationship between an and a0) – this is called recurrence relations between the term of sequence.
MotivationMotivation
Solution:
Since bacteria double every hour Initial condition
By using recursive definition
![Page 6: BCT 2083 DISCRETE STRUCTURE AND APPLICATIONS CHAPTER 2 ADVANCE COUNTING TECHNIQUE SITI ZANARIAH SATARI FSTI/FSKKP UMP I1011](https://reader036.vdocuments.site/reader036/viewer/2022062313/56649c7d5503460f9493309a/html5/thumbnails/6.jpg)
2.1 RECURREN
CE RELATION
• Recursion – a process to define an object explicitly• The object can be a sequence, function or set (for BCT2078 purposes)• The ideas – construct new elements from known elements.• Process – specify some initial elements in a basis step and provide a rule for constructing new elements from those we already have in the recursive step. • Mathematical Induction can be used to prove the result.
Recursive (Inductive) DefinitionsRecursive (Inductive) Definitions
The given complex problem
This simple version can be solved
This simple version can be solved
Can be
solved if
Can be
solved if
Can be
solved if
an = 2an-1 an-1 = 2an-2, a1 = 2a0, a0=5
![Page 7: BCT 2083 DISCRETE STRUCTURE AND APPLICATIONS CHAPTER 2 ADVANCE COUNTING TECHNIQUE SITI ZANARIAH SATARI FSTI/FSKKP UMP I1011](https://reader036.vdocuments.site/reader036/viewer/2022062313/56649c7d5503460f9493309a/html5/thumbnails/7.jpg)
2.1 RECURREN
CE RELATION
• A recursive algorithm provides the solution of a problem of size n in term of the solutions of one or more instances of the same problem in smaller size.
• The initial condition specify the terms that precede the first term where the recurrence elation takes effect.
Recurrence RelationRecurrence Relation
A recurrence relation for the sequence {an} is an equation that expresses an in terms of one or more of the previous terms of the
sequence, namely, a0, a1,…, an-1, for all integers n with n ≥ n0, where n0 is a nonnegative integer.
A sequence is call solution of a recurrence relation if its term satisfy the recurrence relation.
an = 2an-1
a0 = 5 Initial condition
Recurrence relationRecursive definition
![Page 8: BCT 2083 DISCRETE STRUCTURE AND APPLICATIONS CHAPTER 2 ADVANCE COUNTING TECHNIQUE SITI ZANARIAH SATARI FSTI/FSKKP UMP I1011](https://reader036.vdocuments.site/reader036/viewer/2022062313/56649c7d5503460f9493309a/html5/thumbnails/8.jpg)
2.1 RECURREN
CE RELATION
Let {an} be a sequence that satisfies the recurrence relation an = an-1 – an-2 for n = 2, 3,4, and suppose that a0 =3 and a1 = 5.
List the first four term.
a0 = 3 a1 = 5 a2 = a1 – a0 = ___________________ a3 = __________________________
What is a5?
a5 = __________________________
Example 2.1.1Example 2.1.1
![Page 9: BCT 2083 DISCRETE STRUCTURE AND APPLICATIONS CHAPTER 2 ADVANCE COUNTING TECHNIQUE SITI ZANARIAH SATARI FSTI/FSKKP UMP I1011](https://reader036.vdocuments.site/reader036/viewer/2022062313/56649c7d5503460f9493309a/html5/thumbnails/9.jpg)
2.1 RECURREN
CE RELATION
Determine whether {an} where an = 3n for every nonnegative integer n, is a solution of recurrence relation an = 2an-1 – an-2 for n = 2, 3, 4, …
Suppose that an = 3n for every nonnegative integer n, Then for n ≥ 2;
2an-1 – an-2 = ___________________Therefore,
Determine whether {an} where an = 5 for every nonnegative integer n, is a solution of recurrence relation an = 2an-1 – an-2 for n = 2, 3, 4, …
2an-1 – an-2 = ___________________
Example 2.1.2Example 2.1.2
![Page 10: BCT 2083 DISCRETE STRUCTURE AND APPLICATIONS CHAPTER 2 ADVANCE COUNTING TECHNIQUE SITI ZANARIAH SATARI FSTI/FSKKP UMP I1011](https://reader036.vdocuments.site/reader036/viewer/2022062313/56649c7d5503460f9493309a/html5/thumbnails/10.jpg)
2.1 RECURREN
CE RELATION
1. Let an denotes the nth term of a sequence satisfying the given initial condition (s) and the recurrence relation. Compute the first four terms of the sequence.
EXERCISE 2.1EXERCISE 2.1
0 1
1128, for 1
4n na a a n
A
B
C
D
E
1 15, 7 2 for 2n nb b b n
2
1 1 12, 3 2 for 2n n na a a a n
1 2 3 1 2 31, 2, 3, for 4n n n nd d d d d d d n
1 2 1 21, 2, 3 for 3n n na a a a a n
![Page 11: BCT 2083 DISCRETE STRUCTURE AND APPLICATIONS CHAPTER 2 ADVANCE COUNTING TECHNIQUE SITI ZANARIAH SATARI FSTI/FSKKP UMP I1011](https://reader036.vdocuments.site/reader036/viewer/2022062313/56649c7d5503460f9493309a/html5/thumbnails/11.jpg)
2.1 RECURREN
CE RELATION
2. Is the sequence {an} a solution of the if
3. Is the sequence {an} a solution of the if
4. Show that the sequence {an} is a solution of the recurrence relation if
EXERCISE 2.1EXERCISE 2.1
2 1na n 1 23 2n n na a a
1 22 2n n na a a 2 3na n
3n
na 1 23 6n n na a a
![Page 12: BCT 2083 DISCRETE STRUCTURE AND APPLICATIONS CHAPTER 2 ADVANCE COUNTING TECHNIQUE SITI ZANARIAH SATARI FSTI/FSKKP UMP I1011](https://reader036.vdocuments.site/reader036/viewer/2022062313/56649c7d5503460f9493309a/html5/thumbnails/12.jpg)
2.1 RECURREN
CE RELATION
• We can use recurrence relation to model a wide variety of problems such as
– Finding a compound interest– Counting a population of rabbits– Determining the number of moves in the Tower of Hanoi
puzzle– Counting bit strings
Modeling with Recurrence RelationModeling with Recurrence Relation
![Page 13: BCT 2083 DISCRETE STRUCTURE AND APPLICATIONS CHAPTER 2 ADVANCE COUNTING TECHNIQUE SITI ZANARIAH SATARI FSTI/FSKKP UMP I1011](https://reader036.vdocuments.site/reader036/viewer/2022062313/56649c7d5503460f9493309a/html5/thumbnails/13.jpg)
2.1 RECURREN
CE RELATION
Suppose that a person deposits RM10,000 in a savings account at a bank yielding 11% per year with interest compounded annually. Define recursively the compound amount in the account at the end of n years.
Let an : the amount in the account after n yearsThen;
an = (compound amount at the end of (n -1)th years) + (interest for the nth years)
an = an-1 + 0.11an-1 = 1.11 an-1
With initial condition; a0 = 10,000
Example 2.1.3: Compound interestExample 2.1.3: Compound interest
Solution:
![Page 14: BCT 2083 DISCRETE STRUCTURE AND APPLICATIONS CHAPTER 2 ADVANCE COUNTING TECHNIQUE SITI ZANARIAH SATARI FSTI/FSKKP UMP I1011](https://reader036.vdocuments.site/reader036/viewer/2022062313/56649c7d5503460f9493309a/html5/thumbnails/14.jpg)
2.1 RECURREN
CE RELATION
A young pair of rabbits (one of each sex) is placed on an island. A pair of rabbits does not breed until they are 2 months old. After they are 2 months old, each pair of rabbits produces another pair each month. Find a recurrence relation for the numbers of pairs of rabbits on the island after n months if all the rabbits alive.
Let fn : the numbers of pairs of rabbits on the island after n monthsThen;
fn = (number of pairs of rabbits in (n -1)th months) + (number of newborn pairs of rabbits)
fn = fn-1 + fn-2
With initial condition; f1 = 1 and f2 = 1 ; n ≥ 3
Example 2.1.4: Population of rabbitsExample 2.1.4: Population of rabbits
Solution:
WHY???
[Problem develop by Leonardo Pisano (Liber abaci, 13th century) – lead to Fibonacci number]
![Page 15: BCT 2083 DISCRETE STRUCTURE AND APPLICATIONS CHAPTER 2 ADVANCE COUNTING TECHNIQUE SITI ZANARIAH SATARI FSTI/FSKKP UMP I1011](https://reader036.vdocuments.site/reader036/viewer/2022062313/56649c7d5503460f9493309a/html5/thumbnails/15.jpg)
2.1 RECURREN
CE RELATION
Example 2.1.4: Population of rabbitsExample 2.1.4: Population of rabbits
![Page 16: BCT 2083 DISCRETE STRUCTURE AND APPLICATIONS CHAPTER 2 ADVANCE COUNTING TECHNIQUE SITI ZANARIAH SATARI FSTI/FSKKP UMP I1011](https://reader036.vdocuments.site/reader036/viewer/2022062313/56649c7d5503460f9493309a/html5/thumbnails/16.jpg)
2.1 RECURREN
CE RELATION
• Popular Puzzle invented by Edouard Lucas (French Mathematician, late 19th century)
RULES OF PUZZLE:
– Suppose we have 3 pegs labeled A, B, C and a set of disks of different sizes.
– These disks are arranged from the largest disk at the bottom to the smallest disk at the top (1 to n disks) on peg A.
– The goal: to have all disks on peg C in order of size, with the largest on the bottom.
– Only one disk is allow to move at a time from a peg to another.– Each peg must always be arranged from the largest at the
bottom to the smallest at the top
Example 2.1.5: Tower of HanoiExample 2.1.5: Tower of Hanoi
![Page 17: BCT 2083 DISCRETE STRUCTURE AND APPLICATIONS CHAPTER 2 ADVANCE COUNTING TECHNIQUE SITI ZANARIAH SATARI FSTI/FSKKP UMP I1011](https://reader036.vdocuments.site/reader036/viewer/2022062313/56649c7d5503460f9493309a/html5/thumbnails/17.jpg)
2.1 RECURREN
CE RELATION
ILLUSTRATION: SOLUTION
Example 2.1.5: Tower of HanoiExample 2.1.5: Tower of Hanoi
A B C
A B C
Initial Position in the Tower of Hanoi
Intermediate Position in the Tower of Hanoi
n disks
n-1 disks
Hn-1 moves
Let Hn : the numbers of
moves with n disks
transfer the top of n-1 disks to peg B
![Page 18: BCT 2083 DISCRETE STRUCTURE AND APPLICATIONS CHAPTER 2 ADVANCE COUNTING TECHNIQUE SITI ZANARIAH SATARI FSTI/FSKKP UMP I1011](https://reader036.vdocuments.site/reader036/viewer/2022062313/56649c7d5503460f9493309a/html5/thumbnails/18.jpg)
2.1 RECURREN
CE RELATION
ILLUSTRATION: SOLUTION
Example 2.1.5: Tower of HanoiExample 2.1.5: Tower of Hanoi
A B C
A B C
Intermediate Position in the Tower of Hanoi
Last Position in the Tower of Hanoi
1 disks
n disks
Hn-1 moves
Moves the largestdisk to peg C
transfer the top of n-1 disks to peg B
1 move
![Page 19: BCT 2083 DISCRETE STRUCTURE AND APPLICATIONS CHAPTER 2 ADVANCE COUNTING TECHNIQUE SITI ZANARIAH SATARI FSTI/FSKKP UMP I1011](https://reader036.vdocuments.site/reader036/viewer/2022062313/56649c7d5503460f9493309a/html5/thumbnails/19.jpg)
2.1 RECURREN
CE RELATION
Thus the number of moves is given by:
Where:
Example 2.1.5: Tower of HanoiExample 2.1.5: Tower of HanoiSolution (continue):
1 12 1 ; 1n nH H H
Hn-1 moves
Moves the largestdisk to peg C
transfer the top of n-1 disks to peg B
1 moveHn-1 moves
transfer the top of n-1 disks to peg B
+ +
![Page 20: BCT 2083 DISCRETE STRUCTURE AND APPLICATIONS CHAPTER 2 ADVANCE COUNTING TECHNIQUE SITI ZANARIAH SATARI FSTI/FSKKP UMP I1011](https://reader036.vdocuments.site/reader036/viewer/2022062313/56649c7d5503460f9493309a/html5/thumbnails/20.jpg)
2.1 RECURREN
CE RELATION
Find a recurrence relation and give initial conditions for the number of bit strings of length n that do not have two consecutive 0s. How many bit strings are there of six length?
Let an : number of bit strings of length n that do not have two consecutive 0sThen;
an = (number of bit strings of length n-1 that do not have two consecutive 0s) + (number of bit strings of length n-2 that do not have two consecutive 0s)
an = an-1 + an-2 ; n ≥ 3
With initial condition; a1 = 2, both strings of length 1 do not have consecutive 0s ( 0 and 1) a2 = 3, the valid strings only 01, 10 and 11
Example 2.1.6: Bit StringsExample 2.1.6: Bit Strings
Solution:Solve yourself
![Page 21: BCT 2083 DISCRETE STRUCTURE AND APPLICATIONS CHAPTER 2 ADVANCE COUNTING TECHNIQUE SITI ZANARIAH SATARI FSTI/FSKKP UMP I1011](https://reader036.vdocuments.site/reader036/viewer/2022062313/56649c7d5503460f9493309a/html5/thumbnails/21.jpg)
2.1 RECURREN
CE RELATION
A computer system considers a string of decimal digits a valid codeword if it contains an even number of 0 digits. For instance, 1230407869 is valid, whereas 120987045608 is not valid. Let an be the number of valid n-digit codewords. Find a recurrence relation for an.
Let an : the number of valid n-digit codewords Then;
an = (number of valid n-digit codewords obtained by adding a digit other than 0 at the end of a valid string of length n – 1) + (number of valid n-digit codewords obtained by adding a digit 0 at the end of an invalid string of length n – 1)
With initial condition; a1 = 9, there are 10 one-digit strings and only one the string 0 not valid
Example 2.1.7: Example 2.1.7: Codeword enumerationCodeword enumeration
Solution:
1 11 1 19 10 8 10n n
n n n na a a a
![Page 22: BCT 2083 DISCRETE STRUCTURE AND APPLICATIONS CHAPTER 2 ADVANCE COUNTING TECHNIQUE SITI ZANARIAH SATARI FSTI/FSKKP UMP I1011](https://reader036.vdocuments.site/reader036/viewer/2022062313/56649c7d5503460f9493309a/html5/thumbnails/22.jpg)
2.1 RECURREN
CE RELATION
A valid codeword of length n can be formed by:
A) Adding a digit other than 0 at the end of a valid string of length n – 1 - This can be done in nine ways. Hence, a valid string with n digits can be formed in this manner in ways.
B) Adding a digit 0 at the end of an invalid string of length n – 1 - This produces a string with an even number of 0 digits because the invalid string of length n – 1 has an odd number of 0 digits. The number of ways that this can be done equals the number of invalid (n – 1)-digit strings. Because there are strings of length n – 1, and are valid, then there are invalid (n – 1)-digit strings.
Thus;
Example 2.1.7: Example 2.1.7: Codeword enumerationCodeword enumeration
1 11 1 1 19 10 8 10 , 9, 2n n
n n n na A B a a a a n
19 na
110n1na
1110n
na
![Page 23: BCT 2083 DISCRETE STRUCTURE AND APPLICATIONS CHAPTER 2 ADVANCE COUNTING TECHNIQUE SITI ZANARIAH SATARI FSTI/FSKKP UMP I1011](https://reader036.vdocuments.site/reader036/viewer/2022062313/56649c7d5503460f9493309a/html5/thumbnails/23.jpg)
2.1 RECURREN
CE RELATION
6. Define recursively : 1, 4, 7, 10, 13, …
7. Judy deposits RM1500 in a local savings bank at an annual interest rate of 8% compounded annually. Define recursively the compound amount an she will have in her account at the end of n years. How much will be in her account after 3 years?
8. There are n students at a class. Each person shakes hands with everybody else exactly one. Define recursively the number of handshakes that occur.
EXERCISE 2.1EXERCISE 2.1
![Page 24: BCT 2083 DISCRETE STRUCTURE AND APPLICATIONS CHAPTER 2 ADVANCE COUNTING TECHNIQUE SITI ZANARIAH SATARI FSTI/FSKKP UMP I1011](https://reader036.vdocuments.site/reader036/viewer/2022062313/56649c7d5503460f9493309a/html5/thumbnails/24.jpg)
2.1 RECURREN
CE RELATION
9. Find a recurrence relation and initial condition for the number of ways to climb n stairs if the person climbing the stairs can take one, two or three stairs at a time. How many ways can this person climb a building with eight stairs?
10. Find a recurrence relation and initial condition for the number of bit strings of length n that contain three consecutive 0s. How many bit strings of length seven contain three consecutive 0s?
11. Find a recurrence relation for the number of bit sequences of length n with an even number of 0s?
EXERCISE 2.1EXERCISE 2.1
![Page 25: BCT 2083 DISCRETE STRUCTURE AND APPLICATIONS CHAPTER 2 ADVANCE COUNTING TECHNIQUE SITI ZANARIAH SATARI FSTI/FSKKP UMP I1011](https://reader036.vdocuments.site/reader036/viewer/2022062313/56649c7d5503460f9493309a/html5/thumbnails/25.jpg)
2.1 RECURREN
CE RELATION
EXERCISE 2.1 : EXTRAEXERCISE 2.1 : EXTRA
PAGE : 456, 457, 458, 459 and 460
Rosen K.H., Discrete Mathematics & Its Applications, (Seventh Edition), McGraw-Hill, 2007.
![Page 26: BCT 2083 DISCRETE STRUCTURE AND APPLICATIONS CHAPTER 2 ADVANCE COUNTING TECHNIQUE SITI ZANARIAH SATARI FSTI/FSKKP UMP I1011](https://reader036.vdocuments.site/reader036/viewer/2022062313/56649c7d5503460f9493309a/html5/thumbnails/26.jpg)
2.22.2 SOLVING RECURRENCE RELATIONSOLVING RECURRENCE RELATION
• Solve a recurrence relation using iterative method
• Solve a linear homogeneous recurrence relation with constant coefficients
• Solve a linear nonhomogeneous recurrence relation with constant coefficients
CHAPTER 2 AD
VANCE CO
UN
TING
TECHN
IQU
E
![Page 27: BCT 2083 DISCRETE STRUCTURE AND APPLICATIONS CHAPTER 2 ADVANCE COUNTING TECHNIQUE SITI ZANARIAH SATARI FSTI/FSKKP UMP I1011](https://reader036.vdocuments.site/reader036/viewer/2022062313/56649c7d5503460f9493309a/html5/thumbnails/27.jpg)
2.2 SOLVIN
G RECU
RRENCE RELATIO
N
• Solving the recurrence relation for a function f means finding an explicit formula for f (n). The iterative method of solving it involves two steps:
– Apply the recurrence formula iteratively and look for the pattern to predict an explicit formula Forward: start from a0 to an
Backward : start from an to a0
– Use Induction to prove that the formula does indeed hold for every possible value of the integer n.
Iterative MethodIterative Method
![Page 28: BCT 2083 DISCRETE STRUCTURE AND APPLICATIONS CHAPTER 2 ADVANCE COUNTING TECHNIQUE SITI ZANARIAH SATARI FSTI/FSKKP UMP I1011](https://reader036.vdocuments.site/reader036/viewer/2022062313/56649c7d5503460f9493309a/html5/thumbnails/28.jpg)
2.2 SOLVIN
G RECU
RRENCE RELATIO
N
Using the iterative method, predict a solution for the following recurrence relation with the given initial condition.
Example 2.2.1 (a): Iterative MethodExample 2.2.1 (a): Iterative Method
0
1 0
22 1 0 0
2 33 2 0 0
11 0 0
1
2
2 2 2 2
2 2 2 2
2 2 2 2 2 ; 1n n nn n
S
S S
S S S S
S S S S
S S S S n
Solution: (FORWARD)
1 02 ; 1n nS S S
Solution: (BACKWARD)
1
22
33
0
2
2
2
2 2
n n
n
n
n n
S S
S
S
S
![Page 29: BCT 2083 DISCRETE STRUCTURE AND APPLICATIONS CHAPTER 2 ADVANCE COUNTING TECHNIQUE SITI ZANARIAH SATARI FSTI/FSKKP UMP I1011](https://reader036.vdocuments.site/reader036/viewer/2022062313/56649c7d5503460f9493309a/html5/thumbnails/29.jpg)
2.2 SOLVIN
G RECU
RRENCE RELATIO
N
Objective: To proof that the statement P(n) is true for each integer n ≥ n0
Steps:
1. Prove that the statement is true for n = n0.2. Assume that the statement is true for n = k.3. Prove that the statement is true for n = k + 1.4. Conclusion: Therefore, the statement is true
for each integer n ≥ n0
Recall: Mathematical InductionRecall: Mathematical Induction
![Page 30: BCT 2083 DISCRETE STRUCTURE AND APPLICATIONS CHAPTER 2 ADVANCE COUNTING TECHNIQUE SITI ZANARIAH SATARI FSTI/FSKKP UMP I1011](https://reader036.vdocuments.site/reader036/viewer/2022062313/56649c7d5503460f9493309a/html5/thumbnails/30.jpg)
2.2 SOLVIN
G RECU
RRENCE RELATIO
N
Using induction, verify the solution for the recurrence relation is given by .
1. Prove that the statement is true for n = n0.
2. Assume that the statement is true for n = k .
3. Prove that the statement is true for n = k + 1.
4. Conclusion: Therefore, the statement is true for each integer n ≥ n0
Example 2.2.1 (b): InductionExample 2.2.1 (b): Induction
2 ; 1nnS n
Solution:
1 02 ; 1n nS S S
Assume 2 ; 1 is truekkS k
11 2 2S
11 2 2 2 2k k
k kS S
![Page 31: BCT 2083 DISCRETE STRUCTURE AND APPLICATIONS CHAPTER 2 ADVANCE COUNTING TECHNIQUE SITI ZANARIAH SATARI FSTI/FSKKP UMP I1011](https://reader036.vdocuments.site/reader036/viewer/2022062313/56649c7d5503460f9493309a/html5/thumbnails/31.jpg)
2.2 SOLVIN
G RECU
RRENCE RELATIO
N
Suppose that a person deposits RM10,000 in a savings account at a bank yielding 11% per year with interest compounded annually. How much will be in the account after 30 years?
Let an : the amount in the account after n years
Then; an = (compound amount at the end of (n -1)th years)
+ (interest for the nth years) an = an-1 + 0.11an-1 = 1.11 an-1 , n ≥ 1
With initial condition; a0 = 10,000
Example 2.2.2: Compound interestExample 2.2.2: Compound interest
Solution:
![Page 32: BCT 2083 DISCRETE STRUCTURE AND APPLICATIONS CHAPTER 2 ADVANCE COUNTING TECHNIQUE SITI ZANARIAH SATARI FSTI/FSKKP UMP I1011](https://reader036.vdocuments.site/reader036/viewer/2022062313/56649c7d5503460f9493309a/html5/thumbnails/32.jpg)
2.2 SOLVIN
G RECU
RRENCE RELATIO
N
By iterative approach:
Thus, after 30 years the amount in the account will be:
0
1 0
2
2 1 0
3
3 2 0
1 0
10000
1.11
1.11 1.11
1.11 1.11
1.11 1.11 1.11 10000n n
n n
a
a a
a a a
a a a
a a a
Example 2.2.2: Compound interestExample 2.2.2: Compound interestSolution (continue):
30
30 1.11 10000 ___________a
PROVE BY INDUCTION !
![Page 33: BCT 2083 DISCRETE STRUCTURE AND APPLICATIONS CHAPTER 2 ADVANCE COUNTING TECHNIQUE SITI ZANARIAH SATARI FSTI/FSKKP UMP I1011](https://reader036.vdocuments.site/reader036/viewer/2022062313/56649c7d5503460f9493309a/html5/thumbnails/33.jpg)
2.2 SOLVIN
G RECU
RRENCE RELATIO
N
The number of moves is given by:
By iterative approach:
1
22 2
2 3 23 3
1 2 31
1 2 3
2 1
2 2 1 1 2 2 1
2 2 1 2 1 2 2 2 1
2 2 2 2 1
2 2 2 2 1
2 1
n n
n n
n n
n n n
n n n
n
H H
H H
H H
H
Example 2.2.3: Tower of HanoiExample 2.2.3: Tower of Hanoi
1 12 1 ; 1n nH H H PROVE BY
INDUCTION !
![Page 34: BCT 2083 DISCRETE STRUCTURE AND APPLICATIONS CHAPTER 2 ADVANCE COUNTING TECHNIQUE SITI ZANARIAH SATARI FSTI/FSKKP UMP I1011](https://reader036.vdocuments.site/reader036/viewer/2022062313/56649c7d5503460f9493309a/html5/thumbnails/34.jpg)
2.2 SOLVIN
G RECU
RRENCE RELATIO
N
1. Using iterative method, predict a solution to each of the following recurrence relation. Verify the solutions using induction
•
•
2. There are n students at a class. Each person shakes hands with everybody else exactly one. Define recursively the number of handshakes that occur. Solve this recurrence relation using iterative method and prove it using induction.
3. If a deposit of RM100 is made on the first day of each month into an account that pays 6% interest per year compounded monthly, show that the amount in the account after 18 years is RM 38929.
1 04 ; 0 ; 1n na a n a n
EXERCISE 2.2.1EXERCISE 2.2.1
21 1; 1 ; 2n nb b n a n
![Page 35: BCT 2083 DISCRETE STRUCTURE AND APPLICATIONS CHAPTER 2 ADVANCE COUNTING TECHNIQUE SITI ZANARIAH SATARI FSTI/FSKKP UMP I1011](https://reader036.vdocuments.site/reader036/viewer/2022062313/56649c7d5503460f9493309a/html5/thumbnails/35.jpg)
2.2 SOLVIN
G RECU
RRENCE RELATIO
N
A linear homogeneous recurrence relation of degree k with constant coefficients is a recurrence relation of the form
an = c1an-1 + c2an-2 + … + ckan-k
Where c1, c2,…, ck are real numbers and ck ≠ 0
Linear Homogeneous Recurrence Relations with constant coefficients
Linear : The RHS is the sum of previous terms of the sequence each multiplied by a function of n. Homogeneous : No terms occur that are not multiplies of the aj s.Degree k : an is expressed in terms of the previous k terms of the sequenceConstant coefficients : c1, c2,…, ck
Recurrence relation : with k initial condition a0 = C0, a1 = C1, … ak-1= Ck-1
![Page 36: BCT 2083 DISCRETE STRUCTURE AND APPLICATIONS CHAPTER 2 ADVANCE COUNTING TECHNIQUE SITI ZANARIAH SATARI FSTI/FSKKP UMP I1011](https://reader036.vdocuments.site/reader036/viewer/2022062313/56649c7d5503460f9493309a/html5/thumbnails/36.jpg)
2.2 SOLVIN
G RECU
RRENCE RELATIO
N
Linear Homogeneous Recurrence Relation
Pn = (1.11) Pn-1 degree one
fn = fn-1 + fn-2 degree two
an = an-5 degree five
Not Linear Homogeneous Recurrence Relation
Hn = 2Hn-1 + 1
Bn = nBn-1
an = an-1 + a²n-2
Example 2.2.4: Example 2.2.4: Linear Homogeneous RRLinear Homogeneous RR
1. Often occur in modeling of problems
2. Can be systematically solved
![Page 37: BCT 2083 DISCRETE STRUCTURE AND APPLICATIONS CHAPTER 2 ADVANCE COUNTING TECHNIQUE SITI ZANARIAH SATARI FSTI/FSKKP UMP I1011](https://reader036.vdocuments.site/reader036/viewer/2022062313/56649c7d5503460f9493309a/html5/thumbnails/37.jpg)
2.2 SOLVIN
G RECU
RRENCE RELATIO
N
• OUR AIM – look for the solutions of the form , where r is constant.
• Note that, is a solution of the recurrence relation an = c1an-1 + c2an-2 + … + ckan-k iff .
• When both sides of this equation are divided by and the RHS is subtracted from the left, we obtain a characteristic equation:
• The solution of this equation are called the characteristics roots.
Solving Linear Homogeneous Recurrence Relations with constant coefficients
nna r
nna r
1 21 2
n n n n kkr c r c r c r
1 21 2 1 0k k k
k kr c r c r c r c
n kr
![Page 38: BCT 2083 DISCRETE STRUCTURE AND APPLICATIONS CHAPTER 2 ADVANCE COUNTING TECHNIQUE SITI ZANARIAH SATARI FSTI/FSKKP UMP I1011](https://reader036.vdocuments.site/reader036/viewer/2022062313/56649c7d5503460f9493309a/html5/thumbnails/38.jpg)
2.2 SOLVIN
G RECU
RRENCE RELATIO
N
Let c1, c2, …, ck be real numbers. Suppose that the characteristics equation has k distinct roots r1, r2, …, rk.
Then a sequence {an} is a solution of the recurrence relation an = c1an-1 + c2an-2 + … + ckan-k iff for n ≥ 0 and α1, α2, …, αk constant.
If the characteristic equation has several (m) repeated roots, then the solution of the recurrence relation is given by:
Solving Linear Homogeneous Recurrence Relations with constant coefficients
1 1 2 2n n n
n k ka r r r
1 21 2 1 0k k k
k kr c r c r c r c
1 1 2 1 1n n m n n
n m k ka r nr n r r
![Page 39: BCT 2083 DISCRETE STRUCTURE AND APPLICATIONS CHAPTER 2 ADVANCE COUNTING TECHNIQUE SITI ZANARIAH SATARI FSTI/FSKKP UMP I1011](https://reader036.vdocuments.site/reader036/viewer/2022062313/56649c7d5503460f9493309a/html5/thumbnails/39.jpg)
2.2 SOLVIN
G RECU
RRENCE RELATIO
N
Solve the recurrence relation an = 5an-1 - 6an-2 where a0 = 4 and a1 = 7.
1) Find the general solution of the recurrence relation• the characteristic equation is given by • the characteristic roots are 2 and 3• thus, the general solution is
2) Find the constant values, A and B using the initial conditions• Solving the linear system: : A = 5, B = -1
3) Thus the solution to the recurrence relation and initial conditions is .
Example 2.2.5: Example 2.2.5: Second-Order LHRRWCCsSecond-Order LHRRWCCs
Solution:
5 2 3 , 0n nna n
2 3n nna A B
2 5 6 0r r
0
1
4
2 3 7
a A B
a A B
![Page 40: BCT 2083 DISCRETE STRUCTURE AND APPLICATIONS CHAPTER 2 ADVANCE COUNTING TECHNIQUE SITI ZANARIAH SATARI FSTI/FSKKP UMP I1011](https://reader036.vdocuments.site/reader036/viewer/2022062313/56649c7d5503460f9493309a/html5/thumbnails/40.jpg)
2.2 SOLVIN
G RECU
RRENCE RELATIO
N
Solve the recurrence relation an = 6an-1 - 11an-2 + 6an-3 where a0 = 2, a1 =5, and a2 = 15.
1) Find the general solution of the recurrence relation• the characteristic equation is given by • the characteristic roots are 1, 2 and 3• thus, the general solution is
2) Find the constant values, A and B using the initial conditions• Solving the linear system: (A = 1, B = -1, C = 2)
3) Thus the unique solution to the recurrence relation and initial conditions is .
Example 2.2.6: Example 2.2.6: Higher-Order LHRRWCCsHigher-Order LHRRWCCs
Solution:
1 2 2 3 , 0n nna n
1 2 3n n nna A B C
3 26 11 6 0r r r
0 1 22, 2 3 5, 4 9 15a A B C a A B C a A B C
![Page 41: BCT 2083 DISCRETE STRUCTURE AND APPLICATIONS CHAPTER 2 ADVANCE COUNTING TECHNIQUE SITI ZANARIAH SATARI FSTI/FSKKP UMP I1011](https://reader036.vdocuments.site/reader036/viewer/2022062313/56649c7d5503460f9493309a/html5/thumbnails/41.jpg)
2.2 SOLVIN
G RECU
RRENCE RELATIO
N
Suppose that the roots of the characteristic equation of a linear homogenous recurrence relation are 2, 2, 2, 5, 5, and 9. What is the form of general solution?
Thus the general solution to the recurrence relation is
Example 2.2.7: Example 2.2.7: LHRRWCCs with multiple rootsLHRRWCCs with multiple roots
Solution:
2
2
2 2 2 5 5 9
2 5 9
n n n n n nn
n n n
a A Bn Cn D En F
A Bn Cn D En F
![Page 42: BCT 2083 DISCRETE STRUCTURE AND APPLICATIONS CHAPTER 2 ADVANCE COUNTING TECHNIQUE SITI ZANARIAH SATARI FSTI/FSKKP UMP I1011](https://reader036.vdocuments.site/reader036/viewer/2022062313/56649c7d5503460f9493309a/html5/thumbnails/42.jpg)
2.2 SOLVIN
G RECU
RRENCE RELATIO
N
1. What is the solution of the following recurrence relation
•
•
•
2. Find an explicit formula for Fibonacci numbers.
EXERCISE 2.2.2EXERCISE 2.2.2
1 2 0 12 ; 2, 7n n na a a a a
1 2 0 16 9 ; 1, 3n n na a a a a
1 2 3 0 1 23 3 ; 1, 2, 1n n n na a a a a a a
1 2 1 2; 1, 1n n nF F F F F
![Page 43: BCT 2083 DISCRETE STRUCTURE AND APPLICATIONS CHAPTER 2 ADVANCE COUNTING TECHNIQUE SITI ZANARIAH SATARI FSTI/FSKKP UMP I1011](https://reader036.vdocuments.site/reader036/viewer/2022062313/56649c7d5503460f9493309a/html5/thumbnails/43.jpg)
2.2 SOLVIN
G RECU
RRENCE RELATIO
N
• A Linear Nonhomogenous recurrence relation with constant coefficients (LNHRRWCCs), that is a recurrence relation of the form an = c1an-1 + c2an-2 + … + ckan-k + F (n) .
• Where– c1, c2, …, ck are real numbers– F (n) is a function not identically zero depending only n– c1an-1 + c2an-2 + … + ckan-k is called the associated
homogenous recurrence relation
• Example:
Linear NonHomogenous Recurrence Relations with constant coefficients
21 2 1n n na a a n n 12 3n
n na a n 13 2n na a n
![Page 44: BCT 2083 DISCRETE STRUCTURE AND APPLICATIONS CHAPTER 2 ADVANCE COUNTING TECHNIQUE SITI ZANARIAH SATARI FSTI/FSKKP UMP I1011](https://reader036.vdocuments.site/reader036/viewer/2022062313/56649c7d5503460f9493309a/html5/thumbnails/44.jpg)
2.2 SOLVIN
G RECU
RRENCE RELATIO
N
Let be the general solution of c1an-1 + c2an-2 + … + ckan-k
And be the particular solution of LNHRRWCCs,
an = c1an-1 + c2an-2 + … + ckan-k + F (n)
Then the general solution of LNHRRWCCs is given by
There is no general method to find the particular solution.
Solving Linear NonHomogenous Recurrence Relations with constant coefficients
pna
hna
h pn n na a a
![Page 45: BCT 2083 DISCRETE STRUCTURE AND APPLICATIONS CHAPTER 2 ADVANCE COUNTING TECHNIQUE SITI ZANARIAH SATARI FSTI/FSKKP UMP I1011](https://reader036.vdocuments.site/reader036/viewer/2022062313/56649c7d5503460f9493309a/html5/thumbnails/45.jpg)
2.2 SOLVIN
G RECU
RRENCE RELATIO
N
Suppose that {an} satisfy the linear nonhomogenous recurrence relation
And
(i)When s is not a root of the characteristic equation, there is a particular solution of the form
(ii) When s is a root of the characteristic equation , there is a particular solution of the form
THEOREM 6THEOREM 6
1 1 1 2,...,... ( ) where ,n n k n k ka c a c a F n c c c
11 1 0 0 1( ) ( ... ) where , ,..., ,t t n
t t tF n b n b n b n b s b b b s
11 1 0( ... ) t t n
t tp n p n p n p s
11 1 0( ... ) m t t n
t tn p n p n p n p s
![Page 46: BCT 2083 DISCRETE STRUCTURE AND APPLICATIONS CHAPTER 2 ADVANCE COUNTING TECHNIQUE SITI ZANARIAH SATARI FSTI/FSKKP UMP I1011](https://reader036.vdocuments.site/reader036/viewer/2022062313/56649c7d5503460f9493309a/html5/thumbnails/46.jpg)
2.2 SOLVIN
G RECU
RRENCE RELATIO
N
Find all the solutions of recurrence relation an = 3an-1 + 2n
1) Find the general solution of the associated linear homogenous (ALH) equation.
• the ALH equation is given by an = 3an-1 • thus, the general solution is
2) Find the particular solution• Since F(n) = 2n is polynomial with degree 1, then the trial
solution linear function: pn = cn + d (c and d are constant)• The equation an = 3an-1 + 2n then become• Solve for c and d will gives c = -1 and d = -3/2• Thus, the particular solution is
3) Thus the unique solution to the recurrence relation is
Example 2.2.8: Example 2.2.8: LNHRRWCCsLNHRRWCCs
Solution:
3h nna A
33 2n
na A n
3 1 2 0cn d c n d n
32
pna n
![Page 47: BCT 2083 DISCRETE STRUCTURE AND APPLICATIONS CHAPTER 2 ADVANCE COUNTING TECHNIQUE SITI ZANARIAH SATARI FSTI/FSKKP UMP I1011](https://reader036.vdocuments.site/reader036/viewer/2022062313/56649c7d5503460f9493309a/html5/thumbnails/47.jpg)
2.2 SOLVIN
G RECU
RRENCE RELATIO
N
1. What is the solution of the following recurrence relation
•
•
2. What form does a particular solution of linear nonhomogeneous recurrence relation when
EXERCISE 2.2.3EXERCISE 2.2.3
21 2 0 15 6 8 ; 4, 7n n na a a n a a
1 2 0 15 6 7 ; 4, 7nn n na a a a a
1 26 9n n na a a F n
2
2
3 , 3 , 2
4 1 3 , 1 3
n n n
n n
F n F n n F n n
F n n F n n
![Page 48: BCT 2083 DISCRETE STRUCTURE AND APPLICATIONS CHAPTER 2 ADVANCE COUNTING TECHNIQUE SITI ZANARIAH SATARI FSTI/FSKKP UMP I1011](https://reader036.vdocuments.site/reader036/viewer/2022062313/56649c7d5503460f9493309a/html5/thumbnails/48.jpg)
2.2 SOLVIN
G RECU
RRENCE RELATIO
N
EXERCISE 2.2 : EXTRAEXERCISE 2.2 : EXTRA
PAGE : 456, 457, 458, 459 and 460 471, 472, and 473
Rosen K.H., Discrete Mathematics & Its Applications, (Seventh Edition), McGraw-Hill, 2007.
![Page 49: BCT 2083 DISCRETE STRUCTURE AND APPLICATIONS CHAPTER 2 ADVANCE COUNTING TECHNIQUE SITI ZANARIAH SATARI FSTI/FSKKP UMP I1011](https://reader036.vdocuments.site/reader036/viewer/2022062313/56649c7d5503460f9493309a/html5/thumbnails/49.jpg)
2.32.3 DIVIDE-AND-CONQUER RELATIONSDIVIDE-AND-CONQUER RELATIONS
• Describe a divide-and-conquer algorithm
• Analyze the computational complexity of divide-and-conquer algorithm using
recurrence relation
• Estimate the number of operations used by divide-and-conquer algorithm
CHAPTER 2 AD
VANCE CO
UN
TING
TECHN
IQU
E
![Page 50: BCT 2083 DISCRETE STRUCTURE AND APPLICATIONS CHAPTER 2 ADVANCE COUNTING TECHNIQUE SITI ZANARIAH SATARI FSTI/FSKKP UMP I1011](https://reader036.vdocuments.site/reader036/viewer/2022062313/56649c7d5503460f9493309a/html5/thumbnails/50.jpg)
2.3 DIVID
E-AND
-CON
QU
ER RELATION
S
• A procedure is called divide-and-conquer algorithm because
– They DIVIDE a problem into one or more instances of the same problem of smaller size
– &– They CONQUER the problem by using the solutions of
the smaller problems to find a solution of the original problem
• Example:– Binary search– Multiplying integers
Divide-and-Conquer AlgorithmDivide-and-Conquer Algorithm
![Page 51: BCT 2083 DISCRETE STRUCTURE AND APPLICATIONS CHAPTER 2 ADVANCE COUNTING TECHNIQUE SITI ZANARIAH SATARI FSTI/FSKKP UMP I1011](https://reader036.vdocuments.site/reader036/viewer/2022062313/56649c7d5503460f9493309a/html5/thumbnails/51.jpg)
2.3 DIVID
E-AND
-CON
QU
ER RELATION
S
• Suppose that– A recursive algorithm divides a problem of size n into a
subproblems, where each subproblem is of size n/b.– A total of g (n) extra operations are required in the
conquer step of the algorithm to combine the solutions of the subproblems into a solution of the original problem.
• Then, if f (n) represents the number of operations required to solve the problem of size n, it follows that f satisfies the recurrence relation
– f (n) = a f (n/b) + g (n)
• This is called a divide-and conquer recurrence relation
Divide-and-Conquer Recurrence RelationsDivide-and-Conquer Recurrence Relations
![Page 52: BCT 2083 DISCRETE STRUCTURE AND APPLICATIONS CHAPTER 2 ADVANCE COUNTING TECHNIQUE SITI ZANARIAH SATARI FSTI/FSKKP UMP I1011](https://reader036.vdocuments.site/reader036/viewer/2022062313/56649c7d5503460f9493309a/html5/thumbnails/52.jpg)
2.3 DIVID
E-AND
-CON
QU
ER RELATION
S
• What happen in Binary search:– A subproblem is used: The algorithm reduces the search
for an element in a search sequence of size n to the binary search for an element in a search sequence of size n/2, n even.
– g (n) : two comparisons are needed to implement this reduction
1. to determine which half of the list to use2. to determine whether any terms of the list remain
• If f (n) represents the number of comparisons required to search for an element in a search sequence of size n, then
– f (n) = a f (n/b) + g (n) = f (n/2) + 2 , n even
Example 2.3.1: Binary SearchExample 2.3.1: Binary Search
![Page 53: BCT 2083 DISCRETE STRUCTURE AND APPLICATIONS CHAPTER 2 ADVANCE COUNTING TECHNIQUE SITI ZANARIAH SATARI FSTI/FSKKP UMP I1011](https://reader036.vdocuments.site/reader036/viewer/2022062313/56649c7d5503460f9493309a/html5/thumbnails/53.jpg)
2.3 DIVID
E-AND
-CON
QU
ER RELATION
S
• Locating the maximum and minimum elements of a sequence a1, a2, …, an:– 2 subproblems are used:
• If n = 1, then a1 is the maximum and minimum• If n > 1, then the sequence split into 2 sequences ( either where both have
the same number of elements or where one of the sequences has one ore element than the other), let say n/2
• The problem is reduced to find the maximum and minimum of each of the two smaller sequences
• The solution for original problem is the comparison result from these two smaller sequences
– g (n) : two comparisons are needed to implement this reduction 1. to compare the maxima of two sequences2. to compare the minima of two sequences
• If f (n) represents the total number of comparisons needed to find then maximum and minimum elements of the sequence with n elements, then
– f (n) = a f (n/b) + g (n) = 2f (n/2) + 2 , n even
Example 2.3.2: Maximum and MinimumExample 2.3.2: Maximum and Minimum
![Page 54: BCT 2083 DISCRETE STRUCTURE AND APPLICATIONS CHAPTER 2 ADVANCE COUNTING TECHNIQUE SITI ZANARIAH SATARI FSTI/FSKKP UMP I1011](https://reader036.vdocuments.site/reader036/viewer/2022062313/56649c7d5503460f9493309a/html5/thumbnails/54.jpg)
2.3 DIVID
E-AND
-CON
QU
ER RELATION
S
• What happen in Merge Sort: – Splits a list to be sorted with n items, where n even,
into two lists with size n/2 elements each– g (n) : uses fewer than n comparisons to merge the
sorted lists of n/2 items each into one sorted list
• Consequently, the number of comparisons used by the merge sort to sort a list of n element is less than M (n) where,
– M (n) = a f (n/b) + g (n) = 2 M (n/2) + n
Example 2.3.3: Merge SortExample 2.3.3: Merge Sort
![Page 55: BCT 2083 DISCRETE STRUCTURE AND APPLICATIONS CHAPTER 2 ADVANCE COUNTING TECHNIQUE SITI ZANARIAH SATARI FSTI/FSKKP UMP I1011](https://reader036.vdocuments.site/reader036/viewer/2022062313/56649c7d5503460f9493309a/html5/thumbnails/55.jpg)
2.3 DIVID
E-AND
-CON
QU
ER RELATION
S
• Let a, b є N and c, d є R⁺ with b > 1. Let f be an increasing function that satisfies the recurrence relation f (n) = a f (n/b) + c and f (1) = d. Then
• Furthermore, when , where k is a positive integer and a > 1;
where
Theorem 1Theorem 1
log1 2 1 2
b a kf n C n C C a C
kn b
log if 1
log if 1
b aO n af n
O n a
1 21 1 and 1C f c a C c a
![Page 56: BCT 2083 DISCRETE STRUCTURE AND APPLICATIONS CHAPTER 2 ADVANCE COUNTING TECHNIQUE SITI ZANARIAH SATARI FSTI/FSKKP UMP I1011](https://reader036.vdocuments.site/reader036/viewer/2022062313/56649c7d5503460f9493309a/html5/thumbnails/56.jpg)
2.3 DIVID
E-AND
-CON
QU
ER RELATION
S
• Let f (n) = 5 f (n/2) + 3 and f (1) = 7. Find where k is a positive integer. Also estimate f (n) if f is increasing function
Solution:
a = 5, b = 2, c = 3, then
If f is increasing function,
Example 2.3.4Example 2.3.4
1 1 1
5 7 3 4 3 4
5 31 4 3 4
k
k
k
f n a f c a c a
2kf
2log log 5b af n O n O n
![Page 57: BCT 2083 DISCRETE STRUCTURE AND APPLICATIONS CHAPTER 2 ADVANCE COUNTING TECHNIQUE SITI ZANARIAH SATARI FSTI/FSKKP UMP I1011](https://reader036.vdocuments.site/reader036/viewer/2022062313/56649c7d5503460f9493309a/html5/thumbnails/57.jpg)
2.3 DIVID
E-AND
-CON
QU
ER RELATION
S
• Estimate the number of comparisons used by binary search
Solution:
When n is even,
Where f is the number of comparisons required to perform a binary search on a sequence of size n. Hence,
Example 2.3.5: Binary searchExample 2.3.5: Binary search
/ 2 2f n f n
logf n O n
![Page 58: BCT 2083 DISCRETE STRUCTURE AND APPLICATIONS CHAPTER 2 ADVANCE COUNTING TECHNIQUE SITI ZANARIAH SATARI FSTI/FSKKP UMP I1011](https://reader036.vdocuments.site/reader036/viewer/2022062313/56649c7d5503460f9493309a/html5/thumbnails/58.jpg)
2.3 DIVID
E-AND
-CON
QU
ER RELATION
S
• Estimate the number of comparisons used to locate the maximum and minimum elements.
Solution:
When n is even,
Where f is the number of comparisons needed. Hence,
Example 2.3.6: maximum and minimumExample 2.3.6: maximum and minimum
2 / 2 2f n f n
log 2f n O n O n
![Page 59: BCT 2083 DISCRETE STRUCTURE AND APPLICATIONS CHAPTER 2 ADVANCE COUNTING TECHNIQUE SITI ZANARIAH SATARI FSTI/FSKKP UMP I1011](https://reader036.vdocuments.site/reader036/viewer/2022062313/56649c7d5503460f9493309a/html5/thumbnails/59.jpg)
2.3 DIVID
E-AND
-CON
QU
ER RELATION
S
• Let a, b є N and c, d є R⁺ with b > 1. Let f be an increasing function that satisfies the recurrence relation
Then
whenever , where k is a positive integer
Master TheoremMaster Theorem
df n af n b cn
kn b
log
if
log if
if b
d d
d d
a d
O n a b
f n O n n a b
O n a b
![Page 60: BCT 2083 DISCRETE STRUCTURE AND APPLICATIONS CHAPTER 2 ADVANCE COUNTING TECHNIQUE SITI ZANARIAH SATARI FSTI/FSKKP UMP I1011](https://reader036.vdocuments.site/reader036/viewer/2022062313/56649c7d5503460f9493309a/html5/thumbnails/60.jpg)
2.3 DIVID
E-AND
-CON
QU
ER RELATION
S
• Estimate the number of comparisons used by the merge sort to sort a list of n elements.
Solution:
The number of comparisons is less than M (n) where
Hence,
Example 2.3.7: Complexity of merge sortExample 2.3.7: Complexity of merge sort
2 / 2M n M n n
logM n O n n
![Page 61: BCT 2083 DISCRETE STRUCTURE AND APPLICATIONS CHAPTER 2 ADVANCE COUNTING TECHNIQUE SITI ZANARIAH SATARI FSTI/FSKKP UMP I1011](https://reader036.vdocuments.site/reader036/viewer/2022062313/56649c7d5503460f9493309a/html5/thumbnails/61.jpg)
2.2 SOLVIN
G RECU
RRENCE RELATIO
N
1. Find f (n) when where f satisfies the recurrence relation f (n) = 2 f (n/3) + 1 with f (1) = 1. Estimate the solution f (n) if f is an increasing function.
2. Suppose that there are teams in an elimination tournament, where there are n/2 games in the first round, with the winners playing in the second round, and so on.
a. How many rounds are in the elimination tournament when there are 32 teams?
b. Use Divide-and-Conquer algorithm to develop a recurrence relation for the number of rounds in the tournament.
c. Solve the recurrence relation.
EXERCISE 2.3EXERCISE 2.3
3kn
1/ 2 2kn
2kn
![Page 62: BCT 2083 DISCRETE STRUCTURE AND APPLICATIONS CHAPTER 2 ADVANCE COUNTING TECHNIQUE SITI ZANARIAH SATARI FSTI/FSKKP UMP I1011](https://reader036.vdocuments.site/reader036/viewer/2022062313/56649c7d5503460f9493309a/html5/thumbnails/62.jpg)
2.3 DIVID
E-AND
-CON
QU
ER RELATION
S
EXERCISE 2.3 : EXTRAEXERCISE 2.3 : EXTRA
PAGE : 482, 483 and 484
Rosen K.H., Discrete Mathematics & Its Applications, (Seventh Edition), McGraw-Hill, 2007.
![Page 63: BCT 2083 DISCRETE STRUCTURE AND APPLICATIONS CHAPTER 2 ADVANCE COUNTING TECHNIQUE SITI ZANARIAH SATARI FSTI/FSKKP UMP I1011](https://reader036.vdocuments.site/reader036/viewer/2022062313/56649c7d5503460f9493309a/html5/thumbnails/63.jpg)
2.4 GENERATING FUNCTIONS2.4 GENERATING FUNCTIONS
• Represent a sequence as generating function
• Solve counting problems using generating function
• Solve recurrence relation using generating function
CHAPTER 2 AD
VANCE CO
UN
TING
TECHN
IQU
E
![Page 64: BCT 2083 DISCRETE STRUCTURE AND APPLICATIONS CHAPTER 2 ADVANCE COUNTING TECHNIQUE SITI ZANARIAH SATARI FSTI/FSKKP UMP I1011](https://reader036.vdocuments.site/reader036/viewer/2022062313/56649c7d5503460f9493309a/html5/thumbnails/64.jpg)
2.4 GEN
ERATING
FUN
CTION
S
The generating function for the sequence a0, a1,…,ak,… of real numbers is the infinite series
REMARKS:sometimes, this generating function for {ak} is called the ordinary generating function of ak
USEFUL GENERATING FUNCTIONSrefer hand-out or text book page 489 and 157
Generating Function of infinite SequenceGenerating Function of infinite Sequence
0 10
k kk k
k
G x a a x a x a x
formal power series
![Page 65: BCT 2083 DISCRETE STRUCTURE AND APPLICATIONS CHAPTER 2 ADVANCE COUNTING TECHNIQUE SITI ZANARIAH SATARI FSTI/FSKKP UMP I1011](https://reader036.vdocuments.site/reader036/viewer/2022062313/56649c7d5503460f9493309a/html5/thumbnails/65.jpg)
2.4 GEN
ERATING
FUN
CTION
S
The generating function for the following sequences {ak} are given by:
Example 2.4.1Example 2.4.1
0
0
0
3, 3
1, 1
2 , 2
kk
k
kk
k
k k kk
k
a G x x
a k G x k x
a G x x
TIPS: refer handout
![Page 66: BCT 2083 DISCRETE STRUCTURE AND APPLICATIONS CHAPTER 2 ADVANCE COUNTING TECHNIQUE SITI ZANARIAH SATARI FSTI/FSKKP UMP I1011](https://reader036.vdocuments.site/reader036/viewer/2022062313/56649c7d5503460f9493309a/html5/thumbnails/66.jpg)
2.4 GEN
ERATING
FUN
CTION
S
The generating function for the finite sequence a0, a1,…,an of real numbers is define by
REMARKS:
the finite sequence is extend into an infinite sequence by setting an+1 = 0, an+2 = 0, and so on.
Generating Function of finite SequenceGenerating Function of finite Sequence
0 1n
nG x a a x a x
![Page 67: BCT 2083 DISCRETE STRUCTURE AND APPLICATIONS CHAPTER 2 ADVANCE COUNTING TECHNIQUE SITI ZANARIAH SATARI FSTI/FSKKP UMP I1011](https://reader036.vdocuments.site/reader036/viewer/2022062313/56649c7d5503460f9493309a/html5/thumbnails/67.jpg)
2.4 GEN
ERATING
FUN
CTION
S
The generating function for sequences 1,1,1,1,1,1 given by:
The generating function for sequences 1,1,1,1,1,1,… given by:
Example 2.4.2Example 2.4.2
2 3 4 5 11 , 1
1x x x x x x
x
62 3 4 5 1
1 , 11
xx x x x x x
x
WHY?
WHY?
![Page 68: BCT 2083 DISCRETE STRUCTURE AND APPLICATIONS CHAPTER 2 ADVANCE COUNTING TECHNIQUE SITI ZANARIAH SATARI FSTI/FSKKP UMP I1011](https://reader036.vdocuments.site/reader036/viewer/2022062313/56649c7d5503460f9493309a/html5/thumbnails/68.jpg)
2.4 GEN
ERATING
FUN
CTION
S
1. ak is given. Find G(x).
• Let m be a positive integer and ak = C(m,k), for k = 0, 1,…,m. What is the generating function for the sequence a0, a1,…, am?
2. A sequence of integers is given. Find G(x).
• Find the generating function for the finite sequence 1, 4, 16, 64, 256.
3. G(x) is given. Find the sequence of integers.
• A generating function of a sequence is given by (x²+1)³. Find the sequence.
TIPS: Types of questionsTIPS: Types of questions
![Page 69: BCT 2083 DISCRETE STRUCTURE AND APPLICATIONS CHAPTER 2 ADVANCE COUNTING TECHNIQUE SITI ZANARIAH SATARI FSTI/FSKKP UMP I1011](https://reader036.vdocuments.site/reader036/viewer/2022062313/56649c7d5503460f9493309a/html5/thumbnails/69.jpg)
2.4 GEN
ERATING
FUN
CTION
S
1. Find the generating function of the sequence 1, a, a², a³,…
2. Find a closed form of generating function of infinite sequence 0, 1, -2, 4, -8, 16, -32, 64, …
5. Find a closed form of generating function of infinite sequence
6. Find a closed form for generating function for the sequence {an} where an = -1 and an = for all n = 0, 1, 2,…
7. A generating function of a sequence is given by x² /(1 - x) ². Find the sequence.
EXERCISE 2.4.1EXERCISE 2.4.1
2 77 7 7 7,2 ,2 , , 2 ,0,0,
0 1 2 7
8
n
![Page 70: BCT 2083 DISCRETE STRUCTURE AND APPLICATIONS CHAPTER 2 ADVANCE COUNTING TECHNIQUE SITI ZANARIAH SATARI FSTI/FSKKP UMP I1011](https://reader036.vdocuments.site/reader036/viewer/2022062313/56649c7d5503460f9493309a/html5/thumbnails/70.jpg)
2.4 GEN
ERATING
FUN
CTION
S
OBJECTIVE: Solve counting problem
1. to count the number of combinations of various types 2. to count the r-combinations from a set with n elements
when repetition is allowed and additional constraints may exist
3. to count the solutions to equation of the form
e1 + e2 + . . . + en = C
where C is a constant ei is a nonnegative integer that may subject to specified constraint
Counting Problems & Generating FunctionsCounting Problems & Generating Functions
![Page 71: BCT 2083 DISCRETE STRUCTURE AND APPLICATIONS CHAPTER 2 ADVANCE COUNTING TECHNIQUE SITI ZANARIAH SATARI FSTI/FSKKP UMP I1011](https://reader036.vdocuments.site/reader036/viewer/2022062313/56649c7d5503460f9493309a/html5/thumbnails/71.jpg)
2.4 GEN
ERATING
FUN
CTION
S
Find the number of solutions of e1 + e2 + e3 = 17, where e1, e2, and e3 are nonnegative integers with 2 ≤ e1 ≤ 5, 3 ≤ e2 ≤ 6, 4 ≤ e3 ≤ 7 .
Solution
From e1 + e2 + e3 = 17, we know that So, the number of solutions with the indicated constraints is the coefficient of in the expansion of
Since the coefficient is 3, so there are ______ solutions.
HOW?
2 3 4 5 3 4 5 6 4 5 6 7x x x x x x x x x x x x
Example 2.4.4Example 2.4.4
31 2 17ee ex x x x
17x
![Page 72: BCT 2083 DISCRETE STRUCTURE AND APPLICATIONS CHAPTER 2 ADVANCE COUNTING TECHNIQUE SITI ZANARIAH SATARI FSTI/FSKKP UMP I1011](https://reader036.vdocuments.site/reader036/viewer/2022062313/56649c7d5503460f9493309a/html5/thumbnails/72.jpg)
2.4 GEN
ERATING
FUN
CTION
S
In how many different ways can eight identical cookies be distributed among three distinct children if each child receive at least two cookies and no more than four cookies?
Solution
Let e1 : child 1’s cookies, e2: child 2’s cookies, e3: child 3’s cookiesEach child receive at least two cookies and no more than four cookies, so 2 ≤ e1 ≤ 4, 2 ≤ e2 ≤ 4, and 2 ≤ e3 ≤ 4. 8 cookies is distributed among 3 children, so e1 + e2 + e3 = 8 where .Thus the generating function is .
Since the coefficient of is ____, so there are ___ ways.
32 3 4x x x
Example 2.4.5Example 2.4.5
31 2 8ee ex x x x
8x
![Page 73: BCT 2083 DISCRETE STRUCTURE AND APPLICATIONS CHAPTER 2 ADVANCE COUNTING TECHNIQUE SITI ZANARIAH SATARI FSTI/FSKKP UMP I1011](https://reader036.vdocuments.site/reader036/viewer/2022062313/56649c7d5503460f9493309a/html5/thumbnails/73.jpg)
2.4 GEN
ERATING
FUN
CTION
S
1. Use generating functions to determine the number of ways to insert tokens worth RM1, RM5, and RM10 into a vending machine to pay for an item that cost RM r in both the cases when the order in which the tokens are inserted does not matter and when the order does matter.
2. Use generating functions to find the number of ways to make change for RM100 using RM1, RM5, RM10 and RM50.
3. Use generating functions to find the number of ways to select 14 balls from a jar containing 100 red balls, 100 blue balls, and 100 green balls so that no fewer than 3 and no more than 10 balls are selected from each color. Assume that the order in which the balls are drawn does not matter.
EXERCISE 2.4.2EXERCISE 2.4.2
![Page 74: BCT 2083 DISCRETE STRUCTURE AND APPLICATIONS CHAPTER 2 ADVANCE COUNTING TECHNIQUE SITI ZANARIAH SATARI FSTI/FSKKP UMP I1011](https://reader036.vdocuments.site/reader036/viewer/2022062313/56649c7d5503460f9493309a/html5/thumbnails/74.jpg)
2.4 GEN
ERATING
FUN
CTION
S
OBJECTIVE: find a solution to a recurrence relation and its initial conditions by finding an explicit formula for the associated generating function.
TIPS:
1. Let G (x) be the generating function for the sequence {ak}, which
2. Change the sequence ak in the recurrence relation with G (x).3. Solve for G (x).
Recurrence Relations & Generating Recurrence Relations & Generating FunctionsFunctions
11
0 0 1
k k kk k k
k k k
xG x x a x a x a x
0
kk
k
G x a x
and 2 2 22
0 0 2
k k kk k k
k k k
x G x x a x a x a x
![Page 75: BCT 2083 DISCRETE STRUCTURE AND APPLICATIONS CHAPTER 2 ADVANCE COUNTING TECHNIQUE SITI ZANARIAH SATARI FSTI/FSKKP UMP I1011](https://reader036.vdocuments.site/reader036/viewer/2022062313/56649c7d5503460f9493309a/html5/thumbnails/75.jpg)
2.4 GEN
ERATING
FUN
CTION
S
Use generating functions to solve the recurrence relation ak = 3ak-1 for k = 1, 2, 3,… and initial condition a0 = 2.
Solution
By generating function, the recurrence relation ak = 3ak-1 become:
Solving for G (x):
Since .
Consequently;
0 0
22 3 2 3
1 3k k k k
k k
G x x xx
Example 2.4.6Example 2.4.6
0
1
1k k
k
a xax
2 3kka
1 0 10 1 1 1
3 3 3 2 3 2k k k kk k k k k k
k k k k
G x xG x a x a x a a a x a a x
![Page 76: BCT 2083 DISCRETE STRUCTURE AND APPLICATIONS CHAPTER 2 ADVANCE COUNTING TECHNIQUE SITI ZANARIAH SATARI FSTI/FSKKP UMP I1011](https://reader036.vdocuments.site/reader036/viewer/2022062313/56649c7d5503460f9493309a/html5/thumbnails/76.jpg)
2.4 GEN
ERATING
FUN
CTION
S
1. Use generating functions to solve the recurrence relation ak = 7ak-1 + 2 and initial condition a0 = 5.
2. Use generating functions to solve the recurrence relation
and initial condition a0 = 4 and a1 = 12.
3. Suppose that a valid codeword is an n-digit number in decimal notation containing an even number of 0s. Let an denote the number of valid codewords of length n. The sequence {an} satisfies the recurrence relation and the initial condition a1 = 9. Use generating functions to find an explicit formula for an.
1 22 2kk k ka a a
EXERCISE 2.4.2EXERCISE 2.4.2
118 10n
n na a
![Page 77: BCT 2083 DISCRETE STRUCTURE AND APPLICATIONS CHAPTER 2 ADVANCE COUNTING TECHNIQUE SITI ZANARIAH SATARI FSTI/FSKKP UMP I1011](https://reader036.vdocuments.site/reader036/viewer/2022062313/56649c7d5503460f9493309a/html5/thumbnails/77.jpg)
2.4 GEN
ERATING
FUN
CTION
S
EXERCISE 2.4 : EXTRAEXERCISE 2.4 : EXTRA
PAGE : 496, 497, 498 and 499
Rosen K.H., Discrete Mathematics & Its Applications, (Seventh Edition), McGraw-Hill, 2007.
![Page 78: BCT 2083 DISCRETE STRUCTURE AND APPLICATIONS CHAPTER 2 ADVANCE COUNTING TECHNIQUE SITI ZANARIAH SATARI FSTI/FSKKP UMP I1011](https://reader036.vdocuments.site/reader036/viewer/2022062313/56649c7d5503460f9493309a/html5/thumbnails/78.jpg)
2.52.5 INCLUSION-EXCLUSIONINCLUSION-EXCLUSION
• Count the number of elements in the union of more than two sets.
CHAPTER 2 AD
VANCE CO
UN
TING
TECHN
IQU
E
![Page 79: BCT 2083 DISCRETE STRUCTURE AND APPLICATIONS CHAPTER 2 ADVANCE COUNTING TECHNIQUE SITI ZANARIAH SATARI FSTI/FSKKP UMP I1011](https://reader036.vdocuments.site/reader036/viewer/2022062313/56649c7d5503460f9493309a/html5/thumbnails/79.jpg)
Let A1, A2, … An be finite sets. Then:
The number of elements in the union of the two sets A and B is:
The number of elements in the union of the three sets A, B and C is:
2.5 INCLU
SION
-EXCLUSIO
N
1 21 1
1
1
1 2
1
n i i ji n i j n
i j ki j k n
n
n
A A A A A A
A A A
A A A
A B A B A B
The Principle of Inclusion-ExclusionThe Principle of Inclusion-Exclusion
A B C A B C A B B C A C A B C
![Page 80: BCT 2083 DISCRETE STRUCTURE AND APPLICATIONS CHAPTER 2 ADVANCE COUNTING TECHNIQUE SITI ZANARIAH SATARI FSTI/FSKKP UMP I1011](https://reader036.vdocuments.site/reader036/viewer/2022062313/56649c7d5503460f9493309a/html5/thumbnails/80.jpg)
2.5 INCLU
SION
-EXCLUSIO
N
Suppose that there are 1807 freshmen at your school. Of these, 453 are taking a course in computer science, 567 are taking a course in mathematics and 299 are taking course in both computer science and mathematics. How many not taking a course either in computer science or in mathematics?
Solution
Let A: The set of all freshmen taking a course in computer science B: The set of all freshmen taking a course in mathematics Then;
The number of freshmen taking a course either in computer science or in mathematics is
Thus, freshmen not taking a course either in computer science or in mathematics.
1807 721 1086
Example 2.5.1Example 2.5.1
453, 567, 299A B A B
453 567 299 721A B A B A B
![Page 81: BCT 2083 DISCRETE STRUCTURE AND APPLICATIONS CHAPTER 2 ADVANCE COUNTING TECHNIQUE SITI ZANARIAH SATARI FSTI/FSKKP UMP I1011](https://reader036.vdocuments.site/reader036/viewer/2022062313/56649c7d5503460f9493309a/html5/thumbnails/81.jpg)
2.5 INCLU
SION
-EXCLUSIO
N
A total of 1232 have taken a course in Spanish, 879 have taken a course in French and 114 have taken a course in Russian. Further, 103 have taken courses in both Spanish and French, 23 have taken courses in both Spanish and Russian, and 14 have taken courses in both French and Russian. If 2092 students have taken at least one of French, Spanish and Russian, how many students have taken a course in all three languages?
Solution
Let S: The set of students who taken a course in Spanish F: The set of students who taken a course in French R: The set of students who taken a course in Russian Then; The number of students have taken at least one of the languages is given by:
Thus, the number of students have taken a course in all three languages is:
2092 1232 879 114 103 23 14 S F R
Example 2.5.2Example 2.5.2
1232, 879, 114, 103, 23, 14, 2092S F R S F S R F R S F R
7S F R
![Page 82: BCT 2083 DISCRETE STRUCTURE AND APPLICATIONS CHAPTER 2 ADVANCE COUNTING TECHNIQUE SITI ZANARIAH SATARI FSTI/FSKKP UMP I1011](https://reader036.vdocuments.site/reader036/viewer/2022062313/56649c7d5503460f9493309a/html5/thumbnails/82.jpg)
2.5 INCLU
SION
-EXCLUSIO
N
1. How many positive integers not exceeding 1000 are divisible by 7 or 11?
2. To help plan the number of meals to be prepared in a college cafeteria, a survey was conducted and the following data were obtained. 130 students takes breakfast, 180 students takes lunch, 275 students takes dinner, 65 students takes breakfast and lunch, 112 students takes breakfast and dinner, 98 students ate lunch and dinner, and 58 students takes all three meals. How many of the students Ate at least one meal in the cafeteria?
3. How many elements are in the union of four sets if each of the sets has 100 elements, each pair of the sets shares 50 elements, each three of the sets share 25 elements, and there are 5 elements in all four sets?
EXERCISE 2.5EXERCISE 2.5
![Page 83: BCT 2083 DISCRETE STRUCTURE AND APPLICATIONS CHAPTER 2 ADVANCE COUNTING TECHNIQUE SITI ZANARIAH SATARI FSTI/FSKKP UMP I1011](https://reader036.vdocuments.site/reader036/viewer/2022062313/56649c7d5503460f9493309a/html5/thumbnails/83.jpg)
2.5 INCLU
SION
-EXCLUSIO
N
EXERCISE 2.5 : EXTRAEXERCISE 2.5 : EXTRA
PAGE : 504 and 505
Rosen K.H., Discrete Mathematics & Its Applications, (Seventh Edition), McGraw-Hill, 2007.
![Page 84: BCT 2083 DISCRETE STRUCTURE AND APPLICATIONS CHAPTER 2 ADVANCE COUNTING TECHNIQUE SITI ZANARIAH SATARI FSTI/FSKKP UMP I1011](https://reader036.vdocuments.site/reader036/viewer/2022062313/56649c7d5503460f9493309a/html5/thumbnails/84.jpg)
2.62.6 APPLICATION OF INCLUSION-EXCLUSIONAPPLICATION OF INCLUSION-EXCLUSION
• Apply the inclusion-exclusion principle to solve various counting problem
CHAPTER 2 AD
VANCE CO
UN
TING
TECHN
IQU
E
![Page 85: BCT 2083 DISCRETE STRUCTURE AND APPLICATIONS CHAPTER 2 ADVANCE COUNTING TECHNIQUE SITI ZANARIAH SATARI FSTI/FSKKP UMP I1011](https://reader036.vdocuments.site/reader036/viewer/2022062313/56649c7d5503460f9493309a/html5/thumbnails/85.jpg)
2.6 APPLICATION
OF IN
CLUSIO
N-EXCLU
SION
AIM: Solve problem that ask for the number of elements in a set that have none of n properties P1, P2, …, Pn.
• Let Ai: the subset containing the elements that have property Pi
- The number of elements with all the properties Pi1, Pi2, …, Pik will be denoted by N(Pi1, Pi2, …, Pik). In term of set, we have;
• Let N(P1’, Pi’, …, Pi’): the number of elements in a set that have none of n properties P1, P2, …, Pn
and N: number of elements in the set - Thus;• From the inclusion-exclusion principle, we see that:
An Alternative Form of Inclusion-ExclusionAn Alternative Form of Inclusion-Exclusion
1
1 2 1 21 1 1
' ' ' 1n
n i i j i j k ni n i j n i j k n
N P P P N N P N PP N PP P N PP P
1 2 1 2i i ik i i ikA A A N P P P
1 2 1 2' ' 'n nN P P P N A A A
![Page 86: BCT 2083 DISCRETE STRUCTURE AND APPLICATIONS CHAPTER 2 ADVANCE COUNTING TECHNIQUE SITI ZANARIAH SATARI FSTI/FSKKP UMP I1011](https://reader036.vdocuments.site/reader036/viewer/2022062313/56649c7d5503460f9493309a/html5/thumbnails/86.jpg)
2.6 APPLICATION
OF IN
CLUSIO
N-EXCLU
SION
How many solutions does x1 + x2 + x3 = 11 have where x1, x2, x3 are nonnegatives integers with x1 ≤ 3, x2 ≤ 4, and x3 ≤ 6?
Solution
Let a solution have property P1 if x1 > 3P2 if x2 > 4P3 if x3 > 6
The number of solutions satisfying the inequalities x1 ≤ 3, x2 ≤ 4, and x3 ≤ 6 is
1 2 3 1 2 3
1 2 1 3 2 3 1 2 3
' ' 'N P P P N N P N P N P
N PP N PP N P P N PP P
Example 2.6.1Example 2.6.1
![Page 87: BCT 2083 DISCRETE STRUCTURE AND APPLICATIONS CHAPTER 2 ADVANCE COUNTING TECHNIQUE SITI ZANARIAH SATARI FSTI/FSKKP UMP I1011](https://reader036.vdocuments.site/reader036/viewer/2022062313/56649c7d5503460f9493309a/html5/thumbnails/87.jpg)
2.6 APPLICATION
OF IN
CLUSIO
N-EXCLU
SION
By combinations, it follows that:
• N = total number of solutions = C (3+11-1, 11) = 78• N(P1) = (number of solutions with x1 ≥ 4) = C (3+7-1, 7) = 36• N(P2) = (number of solutions with x2 ≥ 5) = C (3+6-1, 6) = 28• N(P3) = (number of solutions with x3 ≥ 7) = C (3+4-1, 4) = 15• N(P1P2) = (number of solutions with x1 ≥ 4 and x2 ≥ 5) = C (3+2-1, 2) = 6• N(P1P3) = (number of solutions with x1 ≥ 4 and x3 ≥ 7) = C (3+0-1, 0) = 1• N(P2P3) = (number of solutions with x2 ≥ 5 and x3 ≥ 7) = 0• N(P1P2P3) = (number of solutions with x1 ≥ 4, x2 ≥ 5 and x3 ≥ 7) = 0
Thus number of solutions satisfying the inequalities x1 ≤ 3, x2 ≤ 4, and x3 ≤ 6 is
1 2 3' ' ' 78 36 28 15 6 1 0 0 6N P P P
Example 2.6.1 : cont…Example 2.6.1 : cont…C(n+r-1, r)
![Page 88: BCT 2083 DISCRETE STRUCTURE AND APPLICATIONS CHAPTER 2 ADVANCE COUNTING TECHNIQUE SITI ZANARIAH SATARI FSTI/FSKKP UMP I1011](https://reader036.vdocuments.site/reader036/viewer/2022062313/56649c7d5503460f9493309a/html5/thumbnails/88.jpg)
2.6 APPLICATION
OF IN
CLUSIO
N-EXCLU
SION
Find the number of prime not exceeding a specified positive integers (ex: 100)
Solution
CLUE: Composite integers not exceeding 100 must have a prime factor not exceeding 10 (WHY?); 2, 3, 5 and 7. Let a solution have property
P1 if an integer is divisible by 2P2 if an integer is divisible by 3 P3 if an integer is divisible by 5 P4 if an integer is divisible by 7
The number of prime not exceeding 100 is
Example 2.6.2: The Sieve of EratosthenesExample 2.6.2: The Sieve of Eratosthenes
1 2 3 44 ' ' ' 'N P P P P
![Page 89: BCT 2083 DISCRETE STRUCTURE AND APPLICATIONS CHAPTER 2 ADVANCE COUNTING TECHNIQUE SITI ZANARIAH SATARI FSTI/FSKKP UMP I1011](https://reader036.vdocuments.site/reader036/viewer/2022062313/56649c7d5503460f9493309a/html5/thumbnails/89.jpg)
2.6 APPLICATION
OF IN
CLUSIO
N-EXCLU
SION
Because there are 99 positive integers greater than 1 and not exceeding 100, the principle of inclusion-exclusion shows that:
Thus, the number of prime not exceeding 100 is
Example 2.6.2: Cont…Example 2.6.2: Cont…
1 2 3 44 ' ' ' ' 4 21 25N P P P P
1 2 3 4 1 2 3 4
1 2 1 3 1 4 2 3 2 4 3 4
1 2 3 1 2 4 1 3 4 2 3 4 1 2 3 4
' ' ' '
99 50 33 20 14 16 10 7 6 4 2 3 2 1 0
21
N P P P P N N P N P N P N P
N PP N PP N PP N P P N P P N P P
N PP P N PP P N PP P N P P P N PP P P
![Page 90: BCT 2083 DISCRETE STRUCTURE AND APPLICATIONS CHAPTER 2 ADVANCE COUNTING TECHNIQUE SITI ZANARIAH SATARI FSTI/FSKKP UMP I1011](https://reader036.vdocuments.site/reader036/viewer/2022062313/56649c7d5503460f9493309a/html5/thumbnails/90.jpg)
2.6 APPLICATION
OF IN
CLUSIO
N-EXCLU
SION
Let m and n be positive integers with m ≥ n. Then there are
onto functions from a set with m elements to a set with n elements
How many onto functions are there from the set with 6 elements to a set with 3 elements?
Solution
Suppose that the elements in the codomain are b1, b2, and b3. Let P1, P2 and P3 be the properties that b1, b2, and b3 are not in the range of the function, respectively. Thus, the number of onto functions is
Example 2.6.3: Example 2.6.3: The Number of Onto FunctionsThe Number of Onto Functions
1,1 1 ,2 2 1 , 1 1
m m nm mn C n n C n n C n n
8x
1 2 3 1 2 3
1 2 1 3 2 3 1 2 3
6 6 6
' ' '
3 3,1 2 3,2 1 729 192 3 540
N P P P N N P N P N P
N PP N PP N P P N PP P
C C
![Page 91: BCT 2083 DISCRETE STRUCTURE AND APPLICATIONS CHAPTER 2 ADVANCE COUNTING TECHNIQUE SITI ZANARIAH SATARI FSTI/FSKKP UMP I1011](https://reader036.vdocuments.site/reader036/viewer/2022062313/56649c7d5503460f9493309a/html5/thumbnails/91.jpg)
2.6 APPLICATION
OF IN
CLUSIO
N-EXCLU
SION
!nD
n
Example 2.6.4: DerangementsExample 2.6.4: Derangements
1 1 1 1! 1 1
1! 2! 3! !n
nD nn
A derangement is a permutation of objects that leaves no object in its original position.
• The permutation 21453 is a derangement of 12345 because no number left in its original position.
• 21543 is not a derangement of 12345 because this permutation leaves 4 in fixed position.
The number of derangements of a sets with n elements is
The probability of a derangement is
![Page 92: BCT 2083 DISCRETE STRUCTURE AND APPLICATIONS CHAPTER 2 ADVANCE COUNTING TECHNIQUE SITI ZANARIAH SATARI FSTI/FSKKP UMP I1011](https://reader036.vdocuments.site/reader036/viewer/2022062313/56649c7d5503460f9493309a/html5/thumbnails/92.jpg)
2.6 APPLICATION
OF IN
CLUSIO
N-EXCLU
SION
1. Find the number of solutions does the equation x1 + x2 + x3 + x4 = 17 have where x1, x2, x3 , x4 are nonnegatives integers with x1 ≤ 3, x2 ≤ 4, and x3 ≤ 5 and x4 ≤ 8 ?
2. How many ways are there to assign five different jobs to four different employees if every employee is assigned at least one job?
3. A new employees checks the hats of n people at a restaurant, forgetting to put claim check numbers on the hats. When customers return for their hats, the checker gives them back hats chosen at random from the remaining hats. What is the probability that no one receive the correct hats?
EXERCISE 2.6 :EXERCISE 2.6 :
![Page 93: BCT 2083 DISCRETE STRUCTURE AND APPLICATIONS CHAPTER 2 ADVANCE COUNTING TECHNIQUE SITI ZANARIAH SATARI FSTI/FSKKP UMP I1011](https://reader036.vdocuments.site/reader036/viewer/2022062313/56649c7d5503460f9493309a/html5/thumbnails/93.jpg)
2.6 APPLICATION
OF IN
CLUSIO
N-EXCLU
SION
EXERCISE 2.6 : EXTRAEXERCISE 2.6 : EXTRA
PAGE : 512 and 513
Rosen K.H., Discrete Mathematics & Its Applications, (Seventh Edition), McGraw-Hill, 2007.
![Page 94: BCT 2083 DISCRETE STRUCTURE AND APPLICATIONS CHAPTER 2 ADVANCE COUNTING TECHNIQUE SITI ZANARIAH SATARI FSTI/FSKKP UMP I1011](https://reader036.vdocuments.site/reader036/viewer/2022062313/56649c7d5503460f9493309a/html5/thumbnails/94.jpg)
CHAPTER 2 AD
VANCE CO
UN
TING
TECHN
IQU
E
SUMMARYSUMMARY
THAT’S ALL ; THANK YOU
• A recurrence relation express terms of a sequence as a function of one or more previous terms of the sequence
• Recurrence relation can be solved using iterative approach and generating functions
• Divide and Conquer algorithm solve a problem recursively by splitting it into a fix number of smaller problems of the same type.
• The inclusion-exclusion principle count the number of elements in the union of more than two sets.
What NEXT?
Chapter 3: Graph