4. THE PRODUCT RULE
• Suppose that a procedure can be broken down into a sequence of two tasks.
• If there are n1 ways to do the first task and for each of these ways of doing the first task,
there are n2 ways to do the second task, then there are n1n2 ways to do the procedure.
4Tahsin Aziz
5. THE PRODUCT RULE
Task 1
N1 way
Task 2
N2 way
Procedure
N1 × N2
possible
ways
5Tahsin Aziz
6. THE PRODUCT RULE
• Example
• How many different bit strings of length seven are there?
• Solution
• Each of the seven bits can be chosen in two ways, because each bit is either 0 or 1. Therefore,
the product rule shows there are a total of 27 = 128 different bit strings of length seven.
0 / 1 × 0 / 1 × 0 / 1 × 0 / 1 × 0 / 1 × 0 / 1 × 0 / 1
2 × 2 × 2 × 2 × 2 × 2 × 2
6Tahsin Aziz
7. THE PRODUCT RULE
• Example
• How many different license plates are available if each plate contains a sequence of three
letters followed by three digits with
a) Repeat allowed
b) Repeat not allowed
7Tahsin Aziz
8. THE PRODUCT RULE
• Solution of a
• There are 26 choices for each of the three letters and ten choices for each of the three digits.
Hence, by the product rule there are a total of 26 × 26 × 26 × 10 × 10 × 10 = 17,576,000
possible license plates.
L × L × L × D × D × D
26 × 26 × 26 × 10 × 10 × 10
8Tahsin Aziz
9. THE PRODUCT RULE
• Solution of b
• There are 26 choices for first letter and as no repeat is allowed so the second letter will have
only 26 – 1 = 25 choices. Accordingly the third letter will have only 26 – 2 = 24 choices.
Similarly there are ten choices for the first digit. Then 10 – 1 = 9 choices for second digit and
10 – 2 = 8 choices for third digit. Hence, by the product rule there are a total of 26 × 25 × 24 ×
10 × 9 × 8 = 11,232,000 possible license plates.
L × L × L × D × D × D
26 × 25 × 24 × 10 × 9 × 8
9Tahsin Aziz
10. THE SUM RULE
• If a task can be done either in one of n1 ways or in one of n2 ways, where none of the set
of n1 ways is the same as any of the set of n2 ways, then there are n1 + n2 ways to do the
task.
10Tahsin Aziz
11. THE SUM RULE
Task 1
N1 way
Task 1
N2 way
Procedure
N1 + N2
possible
ways
11Tahsin Aziz
12. THE SUM RULE
• Example
• A student can choose a computer project from one of three lists. The list A contains 23
projects, list B contains 15 projects and list C contains 19 possible projects. No project is on
more than one list. How many possible projects are there to choose from?
• Solution
• The student can choose a project by selecting a project from the first list, the second list, or the
third list. Because no project is on more than one list, by the sum rule there are 23 + 15 + 19 =
57 ways to choose a project.
23 + 15 + 19
12Tahsin Aziz
13. COMBINATION OF PRODUCT AND SUM RULE
• Many counting problems cannot be solved using just the sum rule or just the product
rule.
• However, many complicated counting problems can be solved using both of these rules
in combination.
13Tahsin Aziz
14. COMBINATION OF PRODUCT AND SUM RULE
• Example
• In a version of the computer language BASIC, the name of a variable is a string of one or two
alphanumeric characters, where uppercase and lowercase letters are not distinguished. (An
alphanumeric character is either one of the 26 English letters or one of the 10 digits.)
Moreover, a variable name must begin with a letter and must be different from the five
strings of two characters that are reserved for programming use. How many different
variable names are there in this version of BASIC?
14Tahsin Aziz
15. COMBINATION OF PRODUCT AND SUM RULE
• Solution
• Let V equal the number of different variable names in this version of BASIC.
• Let V1 be the number of these that are one character long and V2 be the number of these that are two characters
long. Then by the sum rule, V = V1 + V2.
• Note that V1 = 26, because a one-character variable name must be a letter.
• Furthermore, if there are two characters then the first character must be a letter and the second character can be a
letter or an alphanumeric character that is for second character we have 26 + 10 = 36 choices. So, by the product
rule there are 26 × 36 strings of length two that begin with a letter and end with an alphanumeric character.
However, five of these are excluded, so V2 = 26 × 36 − 5 = 931.
• Hence, there are V = V1 + V2 = 26 + 931 = 957 different names for variables in this version of BASIC.
15Tahsin Aziz
16. INCLUSION-EXCLUSION PRINCIPLE
• If a task can be done in either n1 ways or n2 ways, then the number of ways to do the
task is n1 + n2 minus the number of ways to do the task that are common to the two
different ways.
• This rule is also known as “Subtraction Rule”.
• Used in counts where the decomposition yields two count tasks with overlapping
elements. If we use the sum rule some elements would be counted twice. Inclusion –
Exclusion Principle uses a sum rule and then corrects for the overlapping elements.
16Tahsin Aziz
17. INCLUSION-EXCLUSION PRINCIPLE
• Suppose that A1 and A2 are sets. Then, there are |A1| ways to select an element from A1
and |A2| ways to select an element from A2. The number of ways to select an element
from A1 or from A2, that is, the number of ways to select an element from their union, is
the sum of the number of ways to select an element from A1 and the number of ways to
select an element from A2, minus the number of ways to select an element that is in both
A1 and A2. Because there are |A1 ∪ A2| ways to select an element in either A1 or in A2,
and |A1 ∩ A2| ways to select an element common to both sets, we have
• |A1 ∪ A2|=|A1|+|A2|−|A1 ∩ A2|.
17Tahsin Aziz
19. INCLUSION-EXCLUSION PRINCIPLE
• Example
• How many bit strings of length four either start with a ‘0’ or end with ‘11’?
• Solution
• Set A contains bit strings start with 0. So A = 23
• Set B contains bit strings end with 11. So B = 22
• A ∩ B contains bit strings start with 0 and end with 11. So A ∩ B = 21
• Therefore, |A1 ∪ A2|=|A1|+|A2|−|A1 ∩ A2| = 23 + 22 - 21 = 10
0 0 / 1 0 / 1 0 / 1
0 / 1 0 / 1 1 1
0 0 / 1 1 1
19Tahsin Aziz
20. THE PIGEONHOLE PRINCIPLE
• If K is a positive integer and K + 1 or more objects are placed into K boxes, then there is
at least one box containing two or more of the objects.
• Example
• Suppose in a department at least two teachers were born in the same month. Then how many
teachers are there in that department?
• No of months in a year is 12. So numbers of teachers at least (12 + 1) = 13.
20Tahsin Aziz
21. THE GENERALIZED PIGEONHOLE PRINCIPLE
• If N objects are placed into k boxes, then there is at least one box containing at least
N
k
objects.
•
N
k
= m implies that N = k × (m - 1) + 1
21Tahsin Aziz
22. THE GENERALIZED PIGEONHOLE PRINCIPLE
• What is the minimum number of students required in a discrete mathematics class to be
sure that at least six will receive the same grade, if there are five possible grades, A, B, C,
D, and F?
• The minimum number of students needed to ensure that at least six students receive the
same grade is the smallest integer N such that
N
5
= 6. The smallest such integer is N = 5
× 5 + 1 = 26. If you have only 25 students, it is possible for there to be five who have
received each grade so that no six students have received the same grade. Thus, 26 is the
minimum number of students needed to ensure that at least six students will receive the
same grade.
22Tahsin Aziz
23. THE GENERALIZED PIGEONHOLE PRINCIPLE
• Find the minimum number of students in a class to be sure that three of them are born
in the same month.
• Number of students = N
Month = k
N
k
= 3
⇒
N
12
= 3
⇒ N = 12 × (3 - 1) + 1 = 12 × 2 + 1 = 25
23Tahsin Aziz
24. RECURRENCE RELATION
• Recursion
• Recursion means defining an object in terms of itself, part of itself, versions of itself.
• An object can be sequence, function, set, algorithm.
24Tahsin Aziz
25. RECURRENCE RELATION
• Recursively defined sequence
• A sequence is defined recursively whenever some initial terms are specified and later terms
are defined in terms of earlier terms.
• Example
• a0 = 1 and r = 3. The recursively defined sequence is an = an-1 + r where n > 0
• a1 = a0 + 3 = 4
a2 = a1 + 3 = 7 and so on.
So the sequence will be 1, 4, 7, 10, 13, …….
25Tahsin Aziz
26. RECURRENCE RELATION
• There are two steps:
• Base or initial condition
• The first term of the sequence is defined.
• Recursion or recursive step
• The nth term is defined in terms of previous terms.
26Tahsin Aziz
27. RECURRENCE RELATION
• Recursively defined function
• Basic step
• Specify the value of function at 0.
• Recursive step
• Give rule for determining its value at an integer from its value at smaller integers.
27Tahsin Aziz
28. RECURRENCE RELATION
• Example
• 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 number of pairs of rabbits on the
island after n months, assuming that no rabbits ever die.
28Tahsin Aziz
29. RECURRENCE RELATION
• Solution
• Denote by fn the number of pairs of rabbits after n months.
• We will show that fn, n = 1, 2, 3,..., are the terms of the Fibonacci sequence.
• The rabbit population can be modelled using a recurrence relation.
• At the end of the first month, the number of pairs of rabbits on the island is f1 = 1. Because
this pair does not breed during the second month, f2 = 1 also.
29Tahsin Aziz
30. RECURRENCE RELATION
• Solution
• To find the number of pairs after n months, add the number on the island the previous
month, fn−1, and the number of new born pairs, which equals fn−2, because each new born pair
comes from a pair at least 2 months old.
• Consequently, the sequence {fn} satisfies the recurrence relation fn = fn−1 + fn−2 for n ≥ 3
together with the initial conditions f1 = 1 and f2 = 1.
• Because this recurrence relation and the initial conditions uniquely determine this sequence,
the number of pairs of rabbits on the island after n months is given by the nth Fibonacci
number.
30Tahsin Aziz
31. COUNTABLE AND UNCOUNTABLE SETS
• Countable set
• A set that is either finite or has the same cardinality as the set of positive integers is called
countable
• When an infinite set S is countable, we denote the cardinality of S by ℵ0(where ℵ is aleph, the
first letter of the hebrew alphabet). We write |S|=ℵ0 and say that S has cardinality “aleph
null.”
• A finite set is countable. If elements can be described, then also can be counted.
• An infinite set is countable if there is a bijection to it from N. That is its elements can be
indexed.
31Tahsin Aziz
32. COUNTABLE AND UNCOUNTABLE SETS
• Example
{1, 3, 5, 7, …………………..} = O
{0, 1, 2, 3, …………………..} = N
f: N 0 ; f(n) = 2n + 1
32Tahsin Aziz
33. COUNTABLE AND UNCOUNTABLE SETS
• Uncountable set
• A set that is not countable is called uncountable.
• An infinite set is uncountable if there is no bijection to it from N.
33Tahsin Aziz