You are on page 1of 9

INSTITUT TEKNIKAL JEPUN MALAYSIA

JABATAN TENAGA MANUSIA


KEMENTERIAN SUMBER MANUSIA
INSTITUT TEKNIKAL JEPUN MALAYSIA
MALAYSIA

INFORMATION SHEET
CODE AND
J12 DIPLOMA IN COMPUTER ENGINEERING TECHNOLOGY
PROGRAM
NAME
CODE AND
DKB3204 DISCRETE MATHEMATICS
COURSE NAME

TOPIC 5.0 COUNTING

Upon completion of this course students should be able to :


Describe the discrete structures and techniques which can be
COURSE CLO 1
used for solving problems in computing effectively.
LEARNING Identify problems which can be solved using discrete structures
OBJECTIVE CLO 2
and techniques.
Apply the basic of mathematical reasoning, discrete structures,
CLO 3
applications and modeling appropriately.

5.0 COUNTING PRINCIPLES

INTRODUCTION
Suppose that a password on a computer system consists of six, seven, or eight characters. Each
of these characters must be a digit or a letter of the alphabet. Each password must contain at
least one digit. How many such passwords are there? The techniques needed to answer this
question and its known as counting. 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.

5.1 UNDERSTAND COUNTING PRINCIPLES


5.1.1 Basic Counting Principles
 Product Rule
Also called the multiplication rule
If there are m ways to do task 1, and n ways to do task 2
 Then there are m n ways to do both tasks in sequence
Applies when a “procedure” is made up of separate tasks
We must make one choice AND a second choice
1
EXAMPLE

1. There are 18 math majors and 25 science majors. How many ways are there to pick
one math major AND one science majors?

Solution:
 There are 18 ways to select math major and 25 ways to select science major.
 Total is 18  25  450

2. There are 32 microcomputers in a computer center. Each microcomputer has 24


ports. How many different ports to a microcomputer in the center are there?

Solution:

The procedure of choosing a port consists of two tasks, first picking a microcomputer
and then picking a port on this microcomputer. Because there are 32 ways to choose
the micro-computer and 24 ways to choose the port no matter which microcomputer
has been selected, the product rule shows that there are 32·24=768 ports.

3. How many different license plates can be made if each plate contains a sequence of
three uppercase English letters followed by three digits (and no sequences of letters
are prohibited)?

Solution:

There are 26 choices for each of the three uppercase English


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.

 Sum Rule
Also called the addition rule
If there are m ways to do task 1, and n ways to do task 2
If these tasks can be done at the same time, then…

 Then there are m+n ways to do one of the two tasks

We must make one choice OR a second choice

2
EXAMPLES

1. There are 18 math majors and 25 science majors. How many ways are there to pick
one math major OR one science majors?

Solution:
 There are 18 ways to select math major and 25 ways to select science major.
 Total is 18  25  43

2. In how many ways can we select one book from different subjects among five
distinct computer science books, three distinct mathematics books, and two distinct
arts books?

Solutions:

By using Sum Rule,

There are 5 + 3 + 2 = 10 ways to selecting one book from different subject among the
computer science, mathematics and arts books.

5.2 Understand Permutation & Combination

5.2.1 Permutation
 A permutation is the number of ways that that objects can be arranged, in which the
order of the objects matters
 There are basically 2 types of permutation:
a) Permutation Without Repetition
 A permutation of a set of n distinct objects taken r at a time without repetition is
an arrangement of r objects in a specific order.
 We can calculate P(n, r) with the product rule:

P(n, r) = n(n – 1)(n – 2) …(n – r + 1).

(n choices for the first element, (n – 1) for the second one, (n – 2) for the third one…).

 The number of r-permutations of a set with n distinct elements is denoted by


P(n, r).

3
i) Permutations of all elements; P(n,n) = n!

Example

What are the total number of arrangements for the following six balls if all
balls must be used?

ii) Permutations involving some elements from the population;

Example

1. What are the total number of arrangements for the following six balls if only
three balls must be used?

2. In how many ways can you arrange the 3 objects in the set {A, B,C} without
repetition?

Solution:

To arrange all 3 object in the set {A, B,C},


3!  3  2 1
 6
List all of them : ABC, ACB, BAC, BCA, CAB, CBA

3. How many ways are there to select a first prize winner, a second winner, and a third
prize winner from 100 different people who have entered a contest?

Solution :

 Because it does matter which person wins which prizes, use permutations.
 The number of ways to pick the 3 prize winner from 100 people
P100,3  100  99  98
 970200
4
4. A class consists of 10 students. Find the number of ways 3 student can be arranged
without replacement

Solution:

P10,3  10  9  8 10
3 P  720
 720 @

How many permutations of the letter ABCDEFGH contain the string ABC (ABC
occur as a block)?
Solution :

 Because the letter ABC must occur as a block, we can find the number of
permutations of six object :
 Block ABC
 Individual letter (D,E,F,G,H)

 ABC D E F G H

6! = 720

 Hence, there are 720 permutations of the letter ABCDEFGH in which ABC
occurs as a block.

b) 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 × n × ... (r times) = nr

 General Formula;

r
n

where n is the number of things to choose from, and you choose r of them
(Repetition allowed, order matters)

5
EXAMPLE

1. For the lock, there are 10 numbers to choose from (0,1,..9) and you choose 3 of them:

Solution:

10 × 10 × ... (3 times) = 103 = 1,000

2. A password consists of two letters of the alphabet followed by three digits chosen
from 0 to 9. Repetitions are allowed. How many different possible passwords are
there?

Solution:

The number of ways of choosing the letters = 26 × 26 = 676


The number of ways of choosing the digits = 10 × 10 × 10 = 1,000
So the number of possible passwords = 676 × 1,000 = 676,000

5.2.2 Combinations
 A combination is the number of ways that objects can be arranged, in which order of
the objects does not matter.

a) Combination Without Repetition

 A combination of a set of n distinct objects taken r at a time without repetition is


an r-element subset of the n objects.
 The number of combinations of n distinct objects taken r at a time without
repetition is given by

6
EXAMPLE
1. How many committee of three can be formed from seven people?

Solution:
Each committee is a combination of seven people taken three at a time.
Thus, the number of committee can be formed is;
n!
n
C
r!n  r !
r

7!
3C 
7

3!7  3!
7  6  5  4  3  2 1

3  2 1 4  3  2 1
 35

2. In how many ways can we select a committee of two women and three men from a
group of five distinct women and six distinct men?
Solution :

 The committee can be constructed in two ways;


i. Select the women
ii. Select the men

 To select the women;


Combination of two women can be selected from five women is

5!
5
C
2! 5  2!
2

5  4  3  2 1

2  1 3  2  1
120

12
 10

 To select the men;


Combination of three men can be selected from six men is

6!
C
6

3! 6  3!
3

6  5  4  3  2 1

3  2  1 3  2  1
720

36
 20

Hence, by the multiplication Rule, the total number of committee that can be formed is

10  20  200
7
b) Combination With Repetition
 General Formula :

C n  r  1 , r   C n  r  1 , n  1


n  r  1!
r!n  1!

Example

Suppose that a cookie shop has four different kinds of 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.

Solution:

The number of ways to choose six cookies is the number of 6 – combinations of a set
with four elements.

C 4  6  1 , 6  C 4  6  1 , 4  1
C 9,6  C 9,3
98 7

1 2  3
 84

8
IMPORTANT !!!
 If the order does matter it is a Permutation

 If the order doesn't matter, it is a Combination

Combinations & Permutations

With & Without Repetition

Type Repetition Formula


Allowed?

n!
Pn, r 
Permutations No (n  r )!

C n, r  
n!
Combinations No r!n  r !

r
n
Permutations Yes

C n  r  1 , r   C n  r  1 , n  1
Combinations Yes 
n  r  1!
r!n  1!

You might also like