Download as pptx, pdf, or txt
Download as pptx, pdf, or txt
You are on page 1of 20

Discrete Structures

Combinatorics
Ahsan Azhar
Counting
How many triangles are there?
Counting
How many triangles are there?
Counting
How many triangles are there?
Counting
How many triangles are there?
Basic Principles of Counting
List all possible dinners consisting of one main course and one beverage.

HT, HM, HC, HL, CT, CM, CC,CL, FT, FM, FC, FL

Number of possible dinners consisting of one


Appetizer, one Main course, And one Beverage.
Counting: Product Rule
DEFINITION
If an activity/event can be constructed in t successive steps and step 1 can be done in
𝑛1 ways, step 2 can be done in 𝑛2 ways, … , and step t can then be done in 𝑛𝑡 ways
then the number of different possible activities is 𝑛1 × 𝑛2 × ⋯ 𝑛𝑡.
Counting: Product Rule
EXAMPLE 1 Three persons enter into car, where there are 5 seats. In how many
ways can they take up their seats?

Solution:
• The first person has a choice of 5 seats and can sit in any one of those 5
seats. So there are 5 ways of occupying the first seat.
• The second person has a choice of 4 seats.
• Similarly, the third person has a choice of 3 seats.
• Hence, the required number of ways 5x4x3=60.
Counting: Product Rule
EXAMPLE 2 How many strings of length 4 can be formed using the letters ABCDE if
repetitions are not allowed?

EXAMPLE 3 How many strings of part 1 begin with the letter B?

EXAMPLE4 How many strings of part 1 do not begin with the letter B?

EXAMPLE5 In a digital picture, we wish to encode the amount of light at each point as an
eight bit string. How many values are possible at one point?
Counting: Product Rule
EXAMPLE 6 How many eight – bit strings begin either with 101 or 111?

Solution:
• An eight-bit string that begins 101 can be constructed in five successive
steps.
• Select forth bit; select fifth bit;…; select the eight bit. Since each bit can be
selected in two ways, by the multiplication principle,
• 2 × 2 × 2 × 2 × 2 = 25 = 32 eight-bit strings that begin 101.
• Same for 111.
• So the 32 + 32 = 64 eight-bit strings that begins either 101 or 111.
Counting: Sum Rule
DEFINITION
Suppose that 𝑋1, … 𝑋𝑡 are sets and that the ith set 𝑋𝑖 has 𝑛𝑖 elements. If {𝑋1, … 𝑋𝑡} is a
pairwise disjoint family, the number of possible elements that can be selected from 𝑋1
or 𝑋2 or … or 𝑋𝑡 is
𝑛1 + 𝑛2 + ⋯ + 𝑛𝑡.
Counting: Sum Rule
EXAMPLE 1 : if there are 14 boys and 12 girls in a class, find the number of ways of
selecting one student as class representative.

EXAMPLE 2 if a student is getting admission in 4 different engineering colleges and 5


medical colleges, find number of ways of choosing one of the above colleges.
Counting: Sum Rule
EXAMPLE 3 In how many ways can we select two books from different subjects among
five distinct computer science books, three distinct mathematics books, and two distinct
art books?
Solution:
• Using multiplication principle
• Two books from computer & mathematics

• Two books from computer & art

• Two books from mathematics & art

Counting: Sum Rule
EXAMPLE 3 In how many ways can we select two books from different subjects among
five distinct computer science books, three distinct mathematics books, and two distinct
art books?
Solution:
• Since these sets of selections are pairwise disjoints, we may use addition
principle to conclude that


Sequences
Suppose we want to determine the number of strings of length 𝑛 consist of
How many such strings are possible?

We can observe that for the first element of the string, we can choose any of a, b and c, that
is, we have 3 choices. No matter what we choose, there are 3 choices for the second
element of the string, so the number of ways to choose the first two elements is 3 2 = 9.
Proceeding in a similar manner, we get that the number of ways to choose the whole string
is 3n.

THEOREM
The number of strings of length n composed of k given elements is kn.
Sequences
Let us generalize it !!!
Suppose we have a database with 4 fields:

i. 8-characters name  268 Choices


ii. Gender (M/F)  2 Choices
iii. Date of birth (mm-dd-yy)  12 Choices, 31 Choices, 100 Choices
iv. Job code with 13 possibilities  13 Choices

How many entries are possible in the database?

We get that the answer is 268 · 2 · 12 · 31 · 100 · 13 = 201,977,536,857,907,200.


Sequences
THEOREM
Suppose that we want to form strings of length n by using any of a given set of k1
symbols as the first element of the string, any of a given set of k2 symbols as the second
element of the string, etc., any of a given set of kn symbols as the last element of the
string. Then the total number of strings we can form is k1 · k2 · · · kn.

Example: How many numbers are possible with 4 digits? e.g 1000 - 9999

𝟗 × 𝟏𝟎 × 𝟏𝟎 × 𝟏𝟎 = 𝟗 × 𝟏𝟎𝟑
Sequences
Example: How many numbers are possible with 𝒏 digits?

It is clear that the first digit can be any of 9 numbers (1, 2, . . . , 9), while the
second, third, etc., digits can be any of the 10 digits. Thus we get a special case of
the previous question with k1 = 9 and k2 = k3 = · · · = kn = 10. Thus the answer is
9 · 10n−1
Recap
There are some important results:
Number of subsets of an n–set
2𝑛
Number of leaf nodes in a complete binary tree with n levels
2𝑛
Number of binary strings of length 𝑛
2𝑛
Number of possible sequences of length 𝑛 from a set of 𝑘 elements
𝑘𝑛
Number of possible sequences of length 𝑛, if we have 𝑛 objects, each object having 𝑘1
possible symbols/types, 𝑘2 types, …, 𝑘𝑛 types
𝑘1 ⋅ 𝑘 2 ⋅ 𝑘 3 ⋯ 𝑘 𝑛
Thanks!
Do you have any questions?
Ahsan.azhar@ucp.edu.pk
F301 - Cab 2- Building A
University of Central Punjab Lahore

CREDITS: This presentation template was created by Slidesgo, and includes


icons by Flaticon and infographics & images by Freepik

You might also like