DBM20083
Discrete Mathematic
BASIC COUNTING RULES
Lecturer : Madam Azlina Binti Morshidi
Learning Outcome
5.1 Derive counting principle
5.1.1 Describe the used of Counting
5.1.2 Describe with example the following basic decomposition rules/counting
principle
5.1.3 Sum Rule
5.1.4 Product Rule
Identify with example the more complex counting problems typically require a
combination of the sum and product rule.
Solve problem using the basic counting principle rule
Azlina Binti Morshidi/JMSK/PKS
Learning Outcome
5.2 Compute permutation and combinations
5.1.1 Define permutations
5.1.2 Describe permutations with and without repetition
5.1.3 Solve counting problems by using permutations
5.1.4 Describe combination with and without repetition
5.2.5 Solve counting problems by using combinations
Azlina Binti Morshidi/JMSK/PKS
Introduction
Counting problems arise throughout mathematics and
computer science.
For example, we must count the successful outcomes
of experiments and all the possible outcomes of these
experiments to determine probabilities of discrete
events.
We need to count the number of operations used by
an algorithm to study its time complexity.
Azlina Binti Morshidi/JMSK/PKS
Introduction
2 Basic Counting Principles
Product Rule
Sum Rule
Azlina Binti Morshidi/JMSK/PKS
Product Rule
The product rule applies when a procedure is made up
of separate tasks.
Suppose that a procedure can be broken down into a
sequence of two tasks. If there are ways to do the
first task and for each of these ways of doing the first
task, there are ways to do the second task, then
there are ways to the procedure.
Azlina Binti Morshidi/JMSK/PKS
Product Rule (Example #1)
A new company with just 2 employees, Peter and
Jessy, rents a floor of a building with 12 offices. How
many ways are there to assign different offices to
these two employees? Then, since
An office you take
assign to one, so only
me is 12 11 ways left
ways for me…
12 x 11=132 ways
Azlina Binti Morshidi/JMSK/PKS
Product Rule (Example #2)
The chairs of an auditorium are to be labelled with a
letter and a number 1 to 100. How many chairs can be
label?
Letter Number
A-Z 1-100
(26 letters) (100 numbers)
26 x 100=2600 ways
Azlina Binti Morshidi/JMSK/PKS
Product Rule (Example #3)
You buy two pairs of jeans, three shirts and 2 pairs of
shoes, how many new outfits(consisting of a new pair
of jeans, a new shirt, and a new pair of shoes) would
you have?
2 x 3 x 2 = 12 new outfits
Azlina Binti Morshidi/JMSK/PKS
Product Rule (Example #4)
How many different bit strings of length seven are
there?
2 22 222 2
Each bit is
either 1 or 0
= 128 different bit strings of a
length seven
Azlina Binti Morshidi/JMSK/PKS
Product Rule (Example #5)
How many different license plated are available if each
plate consists a sequence of three letters followed by
three digits?
26 26 26 10 10 10
Only have
10 digits….
0-9
There are
26 letters
26 x 26 x 26 x 10 x 10x 10= 17576000
possible license plates
Azlina Binti Morshidi/JMSK/PKS
Product Rule (Example #6)
A serial number consists of two consonants followed
by three nonzero digits followed by a vowel (A,E,I,O,U).
Determine how many serial numbers are possible
given the following conditions.
Letters and digits cannot be repeated in the same
serial number.
Letters and digits can be repeated in the same serial
number.
Azlina Binti Morshidi/JMSK/PKS
Product Rule (Example #6)
A serial number consists of two consonants followed by three nonzero
digits followed by a vowel (A,E,I,O,U). Determine how many serial
numbers are possible given the following conditions.
(a) Letters and digits cannot be repeated in the same serial number.
21 20 9 8 7 5
There are 5 vowels
21 different
choices for the Non zero digits
first consonant
(0-9)
No repeated 21 x 20 x 9 x 8 x 7 x 5 = 1,058,400
letters, Left 20 possible serial numbers
choices for the
second
consonant
Product Rule (Example #6)
A serial number consists of two consonants followed by three nonzero
digits followed by a vowel (A,E,I,O,U). Determine how many serial
numbers are possible given the following conditions.
(b) Letters and digits can be repeated in the same serial number.
21 21 9 9 9 5
There are 5 vowels
21 different
choices for the Non zero digits
first consonant
(0-9)
Repeated 21 x 21 x 9 x 9 x 9 x 5 = 1,607,445
letters, 21 choi possible serial numbers
ces for the
second
consonant
Sum Rule
The sum rule applies if a task can be done either in
one of ways or in one of ways, then there are
+ ways to the task.
Azlina Binti Morshidi/JMSK/PKS
Sum Rule (Example #1)
Suppose that either a member of the ICT faculty or a
student who is a IT major is chosen as a
representative to a university committee. How many
different choices are there for this representative if
there are 37 members of the ICT faculty and 83 IT
majors and no one is both a faculty member and a
student?
Azlina Binti Morshidi/JMSK/PKS
Sum Rule (Example #1)
37 ways from ICT Faculty 83 ways ICT Major
A representative of University Committee
37 + 83 = 120 ways
Sum Rule (Example #2)
A student can choose a computer project from one of
three lists. The three lists contain 23, 15 and 19
possible projects, respectively. No project is on more
than one list. How many possible projects are there
to choose from?
Azlina Binti Morshidi/JMSK/PKS
Sum Rule (Example #2)
List 1: 23 projects 23 + 15 + 19 = 57 ways
List 2: 15 projects
List 3: 19 projects
!!No project is on more than one list.
Azlina Binti Morshidi/JMSK/PKS
Exercise
1. There are 18 mathematics majors and 325 computer
majors at a college.
a) How many ways are there to pick two representative
so that one is a mathematics major and the other is
a computer major.
b) How many ways are there to pick one representative
who is either a mathematics major or a computer
major?
Azlina Binti Morshidi/JMSK/PKS
Exercise
2. A multiple choice test contains 10 questions. There are
four possible answer for each question.
a) How many ways can a student answer the
questions on the test if the student answers
every question?
b) How many ways can a student answer the
question on the test if the student can leave
answers blank?
Azlina Binti Morshidi/JMSK/PKS
Exercise
3. How many different three-letter initials can people have?
4. How many bit strings of length ten both begin and end with a
1?
5. How many license plates can be made using either two
letters followed by four digits, or two digits followed by four
letters?
6. How many license plates can be made using either two or
three letters followed by either two or three digits?
Azlina Binti Morshidi/JMSK/PKS
Permutation
A permutation is an ordered arrangement of all or part
of a set of items.
Example: The three letters P,Q and R can be arranged
the following ways
PQR
PRQ
QPR
QRP
RPQ
RQP
Each of the arrangement is called a permutation of th
e letters P,Q and R.
Azlina Binti Morshidi/JMSK/PKS
Permutation with repetition
When you have n things to choose from, you have n
choices each time.
When choosing r of them, the permutations are n x n
x n …. (r times)
In other words, there are n possibilities for the first
choice then there are n possibilities for the second
choice, and so on, multiplying each time, which is
easier to write down using an exponent of r:
( where n is the number of things to choose from and
you choose r of them- repetition allowed, order
matters)
Azlina Binti Morshidi/JMSK/PKS
Permutation with repetition
(Example)
In the lock , there are 10 numbers to choose from 0-9
and you choose three of them:
10 x 10 x 10 (3 times) = =1000 permutations.
So the formula is simply
Azlina Binti Morshidi/JMSK/PKS
Permutation without repetition
(Example #1)
In how many ways can we select three students from
a group of five students to stand in line for a picture?
In how many ways can we arrange all five of the
students in a line for a picture?
5 x 4 x 3 = 60 ways
= !/ − !
=
54 3
Permutation without repetition
(Example #1)
In how many ways can we select three students from
a group of five students to stand in line for a picture?
In how many ways can we arrange all five of the
students in a line for a picture?
5 x 4 x 3 x 2 x 1 = 120
ways
= !/ − !
=
to arrange the students
54 3 2 1
Permutation without repetition
(Example #2)
In how many ways are there to select a first prize winner, a
second prize winner and a third prize winner from 100
different people who have entered a contest?
Because it matters which person wins which prizes,
the number of ways to pick the three prizes winners
is the number of ordered selections of three
elements from a set of 100 elements, thus is the
number of 3 permutations of a set of 100 elements
100 99 98
100 x 99 x 98 = 970200 ways
= !/ − !
= to select the winner
Permutation without repetition
(Example #3)
Suppose that there are eight runners in a race. The
winner receives a gold medal, the second-place
finisher receives a silver medal and the third place
finisher receives a bronze medal. How many different
ways are there to award these medals, if all possible
outcomes of the race can occur and there are no ties.
876
8 x 7 x 6 = 336 ways
= !/ − !
= to award the medal
Azlina Binti Morshidi/JMSK/PKS
Permutation without repetition
(Example #4)
Suppose that a salesman has to visit eight different
cities. He must begin his trip in a specified city but
he can visit the other seven cities in any order he
wishes. How many possible orders can the salesman
use when visiting these cities.
The number of possible 7 x 6 x 5 x 4 x 3 x 2 x 1 = 5040 ways
paths between = !/ − !
the cities is the number of = for the salesman to
permutations of seven choose the tour
elements because the first
city is determined, but the
remaining seven can be
ordered arbitrarily.
Permutation without repetition
(Example #5)
How many permutations of the letters ABCDEFGH
contain the string ABC?
Because the letters ABC must occur as a block, we can find
the answer by finding the number of permutations of six
objects, namely the block ABC and the individual letters
D, E, F, G and H.
G 6 x 5 x 4 x 3 x 2 x 1 = 720 ways
= !/ − !
= for arrange the letters
Permutation without repetition
(Example #6)
3,2,1 How many permutations of the letters ABCDEFGH
and ABC must be arrange side by side?
Because the letters ABC must arrange side by side, we can
find the answer by finding the number of permutations of
six objects, namely the block ABC and the individual
Letters D, E, F, G and H and ABC also have to be arrange.
G (6 x 5 x 4 x 3 x 2 x 1) x(3 x 2 x 1) = 4320 ways
! !
× = − ! × ( − !)
× = to arrange the letters
Permutation without repetition
(Example #7)
If repetition is not permitted ,
How many 4 digits numbers can be formed
from the six digits 0,1,2,3,4 and 5?
How many are begin with digit 2 or 4 and
must be an even number?
How many are between 2000 and 5000?
Azlina Binti Morshidi/JMSK/PKS
Permutation without repetition
(Example #7)
For the first If repetition is not permitted ,
number , 0 How many 4 digits numbers can be formed
cannot be in from the six digits 0,1,2,3,4 and 5?
the first 012345
Position, so
only have 5 4 20 1
choices
55 43
5 x 5 x 4 x 3 = 300 ways
× = 300 ways to form the 4 digits numbers
Permutation without repetition
(Example #7)
If repetition is not permitted ,
How many are begin with digit 2 or 4 and
For the first must be an even number?
number , only
Since number
have 2
choices 012345 2 or 4 have
number 2 or been chosen
for first digit
4
so only left 2
2 30 4 choices for
the last digit
24 32
2 x 4 x 3 x 2 = 48 ways
× × = 48 ways to form the 4 digits numbers
Permutation without repetition
(Example #7)
If repetition is not permitted ,
How many are between 2000 and 5000?
Digit 2,3 and 012345
4 can be filled 4 30 5
for the first
digit
35 43
3 x 5 x 4 x 3 = 180 ways
× =180 ways to form the 4 digits numbers
Permutation
How many 4 digit numbers can be formed with digit
1,2,3,5,6 and 8 if
No digit can be repeated
The digits can be repeated
The number must be even and no digit can be
repeated
The number must be odd and no digit can be
repeated
Azlina Binti Morshidi/JMSK/PKS
Exercise
1. In how many ways can 7 people be lined up?
2. In how many ways the letters to be arrange without repetition
from the word COMPUTER?
3. How many arrangement can be formed from the words below
a) AMONG
b) MARKET
c) INCLUDE
d) ECONOMICS
e) PROGRAMMERS
4. A password consists of two letters of the alphabet followed by
three digits chosen from 0 to 9. Repeats are allowed. How
many different possible passwords are there?
Azlina Binti Morshidi/JMSK/PKS
Combination
Combinations of a set of objects is a selection of
objects where order does not count. For example,
the combinations of the letters A, B and C taken 2 at
a time are AB, AC and BC.
The following combinations are equal : AB and BA, A
C and CA, BC and CB
The number of combinations of a set with n distinct
elements is denoted by
,
= !/ ! − !
Azlina Binti Morshidi/JMSK/PKS
Combination without repetition
(Example #1)
How many ways to select five players from 10
member tennis team to make a trip to a match at
another school?
, = = !/ ! − !
, = = !/ ! − !
252 combinations
Azlina Binti Morshidi/JMSK/PKS
Combination without repetition
(Example #2)
A group of 30 people have been trained as
astronauts to go on the first mission to Mars. How
many ways are there to select a crew of six people to
go on this mission?
, = = !/ ! − !
, = = !/ ! − !
593775 combinations
Azlina Binti Morshidi/JMSK/PKS
Combination without repetition
(Example #3)
A group of 5 people is chosen randomly from a
committee consists of 5 gentlemen and 6 ladies.
Find how many ways can the people be selected if
(a) there is no restriction
(b) more ladies than gentlemen
Azlina Binti Morshidi/JMSK/PKS
Combination without repetition
(Example #3)
A group of 5 people is chosen randomly from a
committee consists of 5 gentlemen and 6 ladies.
Find how many ways can the people be selected if
(a) there is no restriction
, = = !/ ! − !
, = = !/ ! − !
462 ways
Azlina Binti Morshidi/JMSK/PKS
Combination without repetition
(Example #3)
A group of 5 people is chosen randomly from a
committee consists of 5 gentlemen and 6 ladies. Find
how many ways can the people be selected if
(b) more ladies than gentlemen
Let L denotes the lady and G denoted the gentleman. To choose 5
persons in which more ladies than gentlemen, we need to
consider: L G Number of ways
3 2 6 3 5 2 = 20 × 10 = 200
41 6 4 5 1 = 15 × 5 = 75
50 6 5 5 0 = 6 × 1 = 6
200+75+6= 281 ways
Combination without repetition
(Example #4)
A flower arrangement will be done from 5 tulips and 7
roses. How many combinations can be obtained if
an arrangement that consists of six flowers must:
(a) Have equal number of both types.
(b) Have two roses and four tulips.
(c) Have one, two or three roses.
Azlina Binti Morshidi/JMSK/PKS
Combination with repetition
(Example #1)
How many ways are there to select four pieces of
fruit from a bowl containing apples, oranges, and
pears if the order in which the pieces are selected
does not matter, only the type of fruit and not the
individual piece matters, and there are at least four
pieces of each type of fruit in the bowl?
To solve this problem we list all the ways possible to
select the fruit. There are 15 ways… ( how to
calculate it!!!!!)…lets list it first….
Azlina Binti Morshidi/JMSK/PKS
Combination with repetition
(Example #1)
1. 4 apples + − , = + − , −
2. 4 oranges
3. 4 pears + − , = + − , −
4. 3 apples 1 oranges
5. 3 oranges, 1 apple , = ( , )
6. 3 pears, 1 apples 15 combinations
7. 3 apples, 1 pear
8. 3 oranges, 1 pear
9. 3 pears, 1 orange
10. 2 apples, 1 pear
11. 2 oranges, 2 pears
12. 2 pears, 2 apples
13. 2 apples, 1 orange, 1 pear
14. 2 oranges, 1 apple, 1 pear
15. 2 pears, 1 apple, 1 orange
Combination with repetition
(Example #2)
Suppose that a cookie shop has four different kind
so cookies. How many different ways can six
cookies be chosen? Assume that only the type of
cookie, and not the individual cookies or the order in
which they are chosen matters.
+ − , = + − , −
+ − , = + − , −
, = ( , )
84 combinations
Azlina Binti Morshidi/JMSK/PKS
Exercise
1. From a group of 7 men and 6 women, five persons are to
be selected to form a committee, where there are at least
3 men in the committee. In how many ways can it be
done?
2. A committee consisting of 5 members is chosen from 6
lecturer and 4 students. Find the number of ways if the c
ommittee is made up of:
(a) 3 lecturer and 2 students.
(b) All lecturers
(c) At least 2 lecturers and one student.
(d) One particular lecturer and one particular student.
(e) Not more than 2 lecturers.
Azlina Binti Morshidi/JMSK/PKS
Exercise
3. Five letters are selected from the word “POLYTECHNICS”
and arranged in a straight line. How many five letter words
you can arrange so that they.
(a) Do not have any vowel.
(b) Do not contain letters Y and H.
4. Solve the following problems.
The diagram below show 6 letters and 4 digits.
JKLMN09876
A code is formed by using the letters and digits. Each code
must consists of 3 letters, followed by 2 digits. How many
different codes can be formed if repetition is not allowed.
Azlina Binti Morshidi/JMSK/PKS