SlideShare a Scribd company logo
1 of 30
LECTURE 15
Chapter 5.1
Counting
Prepared by Khairun Nahar,Assistant Professor,
Department of CSE, Comilla University
Basic Counting Principles
We will present two basic counting principles, the product rule
and the sum rule. Then we will show how they can be used to
solve many different counting problems.
THE PRODUCT RULE: Suppose that a procedure can be
broken down into a sequence of two tasks. If there are 𝑛1 ways
to do the first task and for each of these ways of doing the first
task, there are 𝑛2 ways to do the second task, then there are
𝑛1𝑛2 ways to do the procedure.
The product rule applies when a procedure is made up of
separate tasks.
Prepared by Khairun Nahar,Assistant Professor,
Department of CSE, Comilla University
Example-1
Prepared by Khairun Nahar,Assistant Professor,
Department of CSE, Comilla University
Example-2
Example-3
Prepared by Khairun Nahar,Assistant Professor,
Department of CSE, Comilla University
Example-4
Example-5
Prepared by Khairun Nahar,Assistant Professor,
Department of CSE, Comilla University
Example-6
How many functions are there from a set with m elements to a set with n elements?
Example-7
Prepared by Khairun Nahar,Assistant Professor,
Department of CSE, Comilla University
N=5. n-k+1 way=5-3+1=3
M=n
A1->n1
A2->n2
A3->n3
A4->n4
A4->n5
Prepared by Khairun Nahar,Assistant Professor,
Department of CSE, Comilla University
THE SUM RULE If a task can be done either in one of 𝑛1 ways or in
one of 𝑛2 ways, where none of the set of 𝑛1 ways is the same as any of
the set of 𝑛2 ways, then there are 𝑛1 + 𝑛2 ways to do the task.
Example 11: Suppose that either a member of the mathematics faculty
or a student who is a mathematics major is chosen as a representative
to a university committee. How many different choices are there for
this representative if there are 37members of the mathematics faculty
and 83 mathematics majors and no one is both a faculty member and a
student?
Solution: There are 37 ways to choose a member of the mathematics
faculty and there are 83 ways to choose a student who is a mathematics
major. Choosing a member of the mathematics faculty is never the
same as choosing a student who is a mathematics major because no one
is both a faculty member and a student. By the sum rule it follows that
there are 37 +83 = 120 possible ways to pick this representative.
Prepared by Khairun Nahar,Assistant Professor,
Department of CSE, Comilla University
EXAMPLE 14
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?
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, 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.
Prepared by Khairun Nahar,Assistant Professor,
Department of CSE, Comilla University
Assignment
1. There are 18 mathematics majors and 325 computer science majors at a
college.
a) How many ways are there to pick two representatives so that one is a
mathematics major and the other is a computer science major?
b) How many ways are there to pick one representative who is either a
mathematics major or a computer science major?
2. An office building contains 27 floors and has 37 offices on each floor.
How many offices are in the building?
3. A multiple-choice test contains 10 questions. There are four possible
answers 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 questions on the test if the
student can leave answers blank?
Prepared by Khairun Nahar,Assistant Professor,
Department of CSE, Comilla University
4. How many bit strings of length n , where n is a positive
integer, start and end with 1s?
5. How many strings of eight English letters are there
a) that contain no vowels, if letters can be repeated?
b) that contain no vowels, if letters cannot be repeated?
c) that start with a vowel, if letters can be repeated?
d) that start with a vowel, if letters cannot be repeated?
e) that contain at least one vowel, if letters can be repeated?
f) that contain exactly one vowel, if letters can be repeated?
g) that start with X and contain at least one vowel, if
letters can be repeated?
h) that start and end with X and contain at least one vowel, if
letters can be repeated?
Prepared by Khairun Nahar,Assistant Professor,
Department of CSE, Comilla University
a) How many strings of eight English letters are there that
contain no vowels, if letters can be repeated?
=>There are 5 vowels . Then any of 21 letters can appear in any
of the 8 positions, so the answer is 218=37822859361
b) How many strings of eight English letters are there that
contain no vowels, if letters cannot be repeated?
=>The first can be any of 21 letters, the next can’t be the same as
the first, so there are 20 possible letters, the third can be any of
19, etc.
Therefore, the answer is 21×20×19×18×17×16×15×14
=8204716800
that is 21!/13! =8204716800
Prepared by Khairun Nahar,Assistant Professor,
Department of CSE, Comilla University
Solution of Problem (5)
c) How many strings of eight English letters are there that start
with a vowel, if letters can be repeated?
=> Since there are 5 possibilities for the first letter and 26 for
each of the rest. That’s 5 · 267=40159050880
d) How many strings of eight English letters are there that start
with a vowel, if letters cannot be repeated?
=>There are 5 possibilities for the first letter, 25 for the second,
24 for the third, etc. That gives 5·25·24.23.22.21.20.19.18
=12113640000 or 5·25!/17!= 12113640000
e) How many strings of eight English letters are there that
contain at least one vowel, if letters can be repeated?
=>There are 268
strings in all, but only 218
that don’t have a
vowel. Therefore, there are 268
− 218
=171004205215 that have
at least one vowel.
Prepared by Khairun Nahar,Assistant Professor,
Department of CSE, Comilla University
f) How many strings of eight English letters are there that that
contain exactly one vowel, if letters can be repeated?
The vowel (any of 5 possibilities) can occur in any of 8 places,
and the other 7 places each can have any of 21 possible letters.
That gives 5 · 8 · 217
= 72043541640
g) How many strings of eight English letters are there that that
start with X and contain at least one vowel, if letters can be
repeated?
=>There are 267 strings that start with an X, and 217 that don’t
have any vowel, so the answer is 267 − 217=6230721635.
h) How many strings of eight English letters are there that that
start and end with X and contain at least one vowel, if letters
can be repeated?
=>There are 266 strings that start and end with an X, and 216 of
those that don’t have any vowel, so the answer is 266 −
216=223149655.
Prepared by Khairun Nahar,Assistant Professor,
Department of CSE, Comilla University
Chapter 5.2
The Pigeonhole Principle
Prepared by Khairun Nahar,Assistant Professor,
Department of CSE, Comilla University
THE PIGEONHOLE PRINCIPLE
Prepared by Khairun Nahar,Assistant Professor,
Department of CSE, Comilla University
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.
Prepared by Khairun Nahar,Assistant Professor,
Department of CSE, Comilla University
THEOREM 2
THE GENERALIZED PIGEONHOLE PRINCIPLE
If N objects are placed into k boxes, then there is at least one
box containing at least ⌈
𝑁
𝐾
⌉objects.
Proof: We will use a proof by contradiction. Suppose that
none of the boxes contains more than ⌈
𝑁
𝐾
⌉- 1 objects. Then,
the total number of objects is at most
where the inequality ⌈
𝑁
𝐾
⌉ < (
𝑁
𝐾
)+ 1 has been used. This is a
contradiction because there are a total of N objects.
Prepared by Khairun Nahar,Assistant Professor,
Department of CSE, Comilla University
N=6,k=5=> 5x(ceil(1.2)-1)< 5x ((1.2+1)-1);
=> 5x(2-1)< 5.2 But N=6
Prepared by Khairun Nahar,Assistant Professor,
Department of CSE, Comilla University
Exercise-1: Show that in any set of six classes, each meeting
regularly once a week on a particular day of the week, there must be
two that meet on the same day, assuming that no classes are held on
weekends.
Solution: Here are six classes (pigeons), but only five weekdays
(pigeonholes). Therefore, by the pigeonhole principle, at least (⌈
6
5
⌉ )
= 2 classes must be held on the same day.
Exercise-2: Show that if there are 30 students in a class, then at least
two have last names that begin with the same letter.
Solution: We have 26 letters, and 30 students so using Pigeonhole
Principle we have (⌈
30
26
⌉) = 2.
Prepared by Khairun Nahar,Assistant Professor,
Department of CSE, Comilla University
Chapter 5.3
Permutations and Combinations
Prepared by Khairun Nahar,Assistant Professor,
Department of CSE, Comilla University
Permutations
A permutation of a set of distinct objects is an ordered
arrangement of these objects. We also are interested in ordered
arrangements of some of the elements of a set. The word
"permutation" also refers to the act or process of changing the
linear order of an ordered set. An ordered arrangement of r
elements of a set is called an r-permutation.
The number of r-permutations of a set with n elements is denoted
by 𝑷(𝒏 , 𝒓).
Example: Let S = {1 , 2, 3} . The ordered arrangement {3, 1, 2}
is a permutation of S. The ordered arrangement {3, 2} is a 2-
permutation of S.
3-permutation of S are: {1, 2, 3}, {1, 3, 2}, {2, 1, 3}, {2, 3, 1},
{3, 1, 2}, and {3, 2, 1}.
Prepared by Khairun Nahar,Assistant Professor,
Department of CSE, Comilla University
Prepared by Khairun Nahar,Assistant Professor,
Department of CSE, Comilla University
Prepared by Khairun Nahar,Assistant Professor,
Department of CSE, Comilla University
Prepared by Khairun Nahar,Assistant Professor,
Department of CSE, Comilla University
Combinations
The combination is a way of selecting items from a collection,
such that (unlike permutations) the order of selection does not
matter. An 𝑟 −combination of elements of a set is an unordered
selection of r elements from the set. Thus, a 𝑟 −combination is
simply a subset of the set with r elements.
The number of r-combinations of a set with n distinct elements is
denoted by 𝐶(𝑛, 𝑟 ).
Note that 𝐶(𝑛 , 𝑟) is also denoted by (𝑛
𝑟
) and is called a binomial
coefficient.
Prepared by Khairun Nahar,Assistant Professor,
Department of CSE, Comilla University
Prepared by Khairun Nahar,Assistant Professor,
Department of CSE, Comilla University
Permutation and Combination
S1={a,b,c} S2={Saimon, Rahim, Karim} n=3
S1={a,b},{b,c},{c,a},{a,c},{b,a},{c,b}=6 way= permutation
S2={Saimon,Rahim} =3 way= combination
{Saimon, Karim}
{Rahim,Karim}
{Rahim, Saimon}
{Karim, Saimon}
{Karim, Rahim}
Prepared by Khairun Nahar,Assistant Professor,
Department of CSE, Comilla University
Prepared by Khairun Nahar,Assistant Professor,
Department of CSE, Comilla University
Relation between Permutation and Combination
P(n , r) = C (n, r)× r !
Permutation Formula Combination Formula
Prepared by Khairun Nahar,Assistant Professor,
Department of CSE, Comilla University

More Related Content

Similar to Counting Principles and Pigeonhole Principle

K TO 12 GRADE 7 LEARNING MODULE IN MATHEMATICS (Quarter 3)
K TO 12 GRADE 7 LEARNING MODULE IN MATHEMATICS (Quarter 3)K TO 12 GRADE 7 LEARNING MODULE IN MATHEMATICS (Quarter 3)
K TO 12 GRADE 7 LEARNING MODULE IN MATHEMATICS (Quarter 3)LiGhT ArOhL
 
G6 m4-b-lesson 5-t
G6 m4-b-lesson 5-tG6 m4-b-lesson 5-t
G6 m4-b-lesson 5-tmlabuski
 
G6 m4-g-lesson 24-t
G6 m4-g-lesson 24-tG6 m4-g-lesson 24-t
G6 m4-g-lesson 24-tmlabuski
 
Special webinar on tips for perfect score in sat math
Special webinar on tips for perfect score in sat mathSpecial webinar on tips for perfect score in sat math
Special webinar on tips for perfect score in sat mathCareerGOD
 
counting principle.ppt
counting principle.pptcounting principle.ppt
counting principle.pptRizaCatli2
 
Permutation Combination
Permutation Combination Permutation Combination
Permutation Combination RizwanManzoor15
 
Educational Psychology 565 Practice Quiz(use α = .05 unl.docx
Educational Psychology 565 Practice Quiz(use α = .05 unl.docxEducational Psychology 565 Practice Quiz(use α = .05 unl.docx
Educational Psychology 565 Practice Quiz(use α = .05 unl.docxtoltonkendal
 
G6 m4-d-lesson 11-s
G6 m4-d-lesson 11-sG6 m4-d-lesson 11-s
G6 m4-d-lesson 11-smlabuski
 
G6 m4-a-lesson 1-t
G6 m4-a-lesson 1-tG6 m4-a-lesson 1-t
G6 m4-a-lesson 1-tmlabuski
 
G6 m1-b-lesson 9-t
G6 m1-b-lesson 9-tG6 m1-b-lesson 9-t
G6 m1-b-lesson 9-tmlabuski
 
G6 m5-c-lesson 12-t
G6 m5-c-lesson 12-tG6 m5-c-lesson 12-t
G6 m5-c-lesson 12-tmlabuski
 
Chapter 3 - Problem Solving.pdf
Chapter 3 - Problem Solving.pdfChapter 3 - Problem Solving.pdf
Chapter 3 - Problem Solving.pdfMinaSaflor
 
Mathematical Statistics Homework Help
Mathematical Statistics Homework HelpMathematical Statistics Homework Help
Mathematical Statistics Homework HelpExcel Homework Help
 
Generating Patterns and arithmetic sequence.pptx
Generating Patterns and arithmetic sequence.pptxGenerating Patterns and arithmetic sequence.pptx
Generating Patterns and arithmetic sequence.pptxRenoLope1
 

Similar to Counting Principles and Pigeonhole Principle (20)

K TO 12 GRADE 7 LEARNING MODULE IN MATHEMATICS (Quarter 3)
K TO 12 GRADE 7 LEARNING MODULE IN MATHEMATICS (Quarter 3)K TO 12 GRADE 7 LEARNING MODULE IN MATHEMATICS (Quarter 3)
K TO 12 GRADE 7 LEARNING MODULE IN MATHEMATICS (Quarter 3)
 
G6 m4-b-lesson 5-t
G6 m4-b-lesson 5-tG6 m4-b-lesson 5-t
G6 m4-b-lesson 5-t
 
WEEK 8.docx
WEEK 8.docxWEEK 8.docx
WEEK 8.docx
 
G6 m4-g-lesson 24-t
G6 m4-g-lesson 24-tG6 m4-g-lesson 24-t
G6 m4-g-lesson 24-t
 
PermutATIONS
PermutATIONSPermutATIONS
PermutATIONS
 
Schl2008
Schl2008Schl2008
Schl2008
 
Special webinar on tips for perfect score in sat math
Special webinar on tips for perfect score in sat mathSpecial webinar on tips for perfect score in sat math
Special webinar on tips for perfect score in sat math
 
counting principle.ppt
counting principle.pptcounting principle.ppt
counting principle.ppt
 
Permutation Combination
Permutation Combination Permutation Combination
Permutation Combination
 
Educational Psychology 565 Practice Quiz(use α = .05 unl.docx
Educational Psychology 565 Practice Quiz(use α = .05 unl.docxEducational Psychology 565 Practice Quiz(use α = .05 unl.docx
Educational Psychology 565 Practice Quiz(use α = .05 unl.docx
 
G6 m4-d-lesson 11-s
G6 m4-d-lesson 11-sG6 m4-d-lesson 11-s
G6 m4-d-lesson 11-s
 
G6 m4-a-lesson 1-t
G6 m4-a-lesson 1-tG6 m4-a-lesson 1-t
G6 m4-a-lesson 1-t
 
G6 m1-b-lesson 9-t
G6 m1-b-lesson 9-tG6 m1-b-lesson 9-t
G6 m1-b-lesson 9-t
 
G6 m5-c-lesson 12-t
G6 m5-c-lesson 12-tG6 m5-c-lesson 12-t
G6 m5-c-lesson 12-t
 
G8DLL_Q2W1_LC22-23.docx
G8DLL_Q2W1_LC22-23.docxG8DLL_Q2W1_LC22-23.docx
G8DLL_Q2W1_LC22-23.docx
 
Chapter2009
Chapter2009Chapter2009
Chapter2009
 
Chapter 3 - Problem Solving.pdf
Chapter 3 - Problem Solving.pdfChapter 3 - Problem Solving.pdf
Chapter 3 - Problem Solving.pdf
 
Chapter 12.pptx
Chapter 12.pptxChapter 12.pptx
Chapter 12.pptx
 
Mathematical Statistics Homework Help
Mathematical Statistics Homework HelpMathematical Statistics Homework Help
Mathematical Statistics Homework Help
 
Generating Patterns and arithmetic sequence.pptx
Generating Patterns and arithmetic sequence.pptxGenerating Patterns and arithmetic sequence.pptx
Generating Patterns and arithmetic sequence.pptx
 

Recently uploaded

Study on Air-Water & Water-Water Heat Exchange in a Finned Tube Exchanger
Study on Air-Water & Water-Water Heat Exchange in a Finned Tube ExchangerStudy on Air-Water & Water-Water Heat Exchange in a Finned Tube Exchanger
Study on Air-Water & Water-Water Heat Exchange in a Finned Tube ExchangerAnamika Sarkar
 
CCS355 Neural Network & Deep Learning Unit II Notes with Question bank .pdf
CCS355 Neural Network & Deep Learning Unit II Notes with Question bank .pdfCCS355 Neural Network & Deep Learning Unit II Notes with Question bank .pdf
CCS355 Neural Network & Deep Learning Unit II Notes with Question bank .pdfAsst.prof M.Gokilavani
 
VICTOR MAESTRE RAMIREZ - Planetary Defender on NASA's Double Asteroid Redirec...
VICTOR MAESTRE RAMIREZ - Planetary Defender on NASA's Double Asteroid Redirec...VICTOR MAESTRE RAMIREZ - Planetary Defender on NASA's Double Asteroid Redirec...
VICTOR MAESTRE RAMIREZ - Planetary Defender on NASA's Double Asteroid Redirec...VICTOR MAESTRE RAMIREZ
 
GDSC ASEB Gen AI study jams presentation
GDSC ASEB Gen AI study jams presentationGDSC ASEB Gen AI study jams presentation
GDSC ASEB Gen AI study jams presentationGDSCAESB
 
OSVC_Meta-Data based Simulation Automation to overcome Verification Challenge...
OSVC_Meta-Data based Simulation Automation to overcome Verification Challenge...OSVC_Meta-Data based Simulation Automation to overcome Verification Challenge...
OSVC_Meta-Data based Simulation Automation to overcome Verification Challenge...Soham Mondal
 
Sheet Pile Wall Design and Construction: A Practical Guide for Civil Engineer...
Sheet Pile Wall Design and Construction: A Practical Guide for Civil Engineer...Sheet Pile Wall Design and Construction: A Practical Guide for Civil Engineer...
Sheet Pile Wall Design and Construction: A Practical Guide for Civil Engineer...Dr.Costas Sachpazis
 
(MEERA) Dapodi Call Girls Just Call 7001035870 [ Cash on Delivery ] Pune Escorts
(MEERA) Dapodi Call Girls Just Call 7001035870 [ Cash on Delivery ] Pune Escorts(MEERA) Dapodi Call Girls Just Call 7001035870 [ Cash on Delivery ] Pune Escorts
(MEERA) Dapodi Call Girls Just Call 7001035870 [ Cash on Delivery ] Pune Escortsranjana rawat
 
Call Girls Narol 7397865700 Independent Call Girls
Call Girls Narol 7397865700 Independent Call GirlsCall Girls Narol 7397865700 Independent Call Girls
Call Girls Narol 7397865700 Independent Call Girlsssuser7cb4ff
 
power system scada applications and uses
power system scada applications and usespower system scada applications and uses
power system scada applications and usesDevarapalliHaritha
 
Internship report on mechanical engineering
Internship report on mechanical engineeringInternship report on mechanical engineering
Internship report on mechanical engineeringmalavadedarshan25
 
chaitra-1.pptx fake news detection using machine learning
chaitra-1.pptx  fake news detection using machine learningchaitra-1.pptx  fake news detection using machine learning
chaitra-1.pptx fake news detection using machine learningmisbanausheenparvam
 
HARMONY IN THE HUMAN BEING - Unit-II UHV-2
HARMONY IN THE HUMAN BEING - Unit-II UHV-2HARMONY IN THE HUMAN BEING - Unit-II UHV-2
HARMONY IN THE HUMAN BEING - Unit-II UHV-2RajaP95
 
VIP Call Girls Service Hitech City Hyderabad Call +91-8250192130
VIP Call Girls Service Hitech City Hyderabad Call +91-8250192130VIP Call Girls Service Hitech City Hyderabad Call +91-8250192130
VIP Call Girls Service Hitech City Hyderabad Call +91-8250192130Suhani Kapoor
 
Microscopic Analysis of Ceramic Materials.pptx
Microscopic Analysis of Ceramic Materials.pptxMicroscopic Analysis of Ceramic Materials.pptx
Microscopic Analysis of Ceramic Materials.pptxpurnimasatapathy1234
 
SPICE PARK APR2024 ( 6,793 SPICE Models )
SPICE PARK APR2024 ( 6,793 SPICE Models )SPICE PARK APR2024 ( 6,793 SPICE Models )
SPICE PARK APR2024 ( 6,793 SPICE Models )Tsuyoshi Horigome
 
Architect Hassan Khalil Portfolio for 2024
Architect Hassan Khalil Portfolio for 2024Architect Hassan Khalil Portfolio for 2024
Architect Hassan Khalil Portfolio for 2024hassan khalil
 
What are the advantages and disadvantages of membrane structures.pptx
What are the advantages and disadvantages of membrane structures.pptxWhat are the advantages and disadvantages of membrane structures.pptx
What are the advantages and disadvantages of membrane structures.pptxwendy cai
 
Heart Disease Prediction using machine learning.pptx
Heart Disease Prediction using machine learning.pptxHeart Disease Prediction using machine learning.pptx
Heart Disease Prediction using machine learning.pptxPoojaBan
 
Gfe Mayur Vihar Call Girls Service WhatsApp -> 9999965857 Available 24x7 ^ De...
Gfe Mayur Vihar Call Girls Service WhatsApp -> 9999965857 Available 24x7 ^ De...Gfe Mayur Vihar Call Girls Service WhatsApp -> 9999965857 Available 24x7 ^ De...
Gfe Mayur Vihar Call Girls Service WhatsApp -> 9999965857 Available 24x7 ^ De...srsj9000
 

Recently uploaded (20)

Study on Air-Water & Water-Water Heat Exchange in a Finned Tube Exchanger
Study on Air-Water & Water-Water Heat Exchange in a Finned Tube ExchangerStudy on Air-Water & Water-Water Heat Exchange in a Finned Tube Exchanger
Study on Air-Water & Water-Water Heat Exchange in a Finned Tube Exchanger
 
CCS355 Neural Network & Deep Learning Unit II Notes with Question bank .pdf
CCS355 Neural Network & Deep Learning Unit II Notes with Question bank .pdfCCS355 Neural Network & Deep Learning Unit II Notes with Question bank .pdf
CCS355 Neural Network & Deep Learning Unit II Notes with Question bank .pdf
 
VICTOR MAESTRE RAMIREZ - Planetary Defender on NASA's Double Asteroid Redirec...
VICTOR MAESTRE RAMIREZ - Planetary Defender on NASA's Double Asteroid Redirec...VICTOR MAESTRE RAMIREZ - Planetary Defender on NASA's Double Asteroid Redirec...
VICTOR MAESTRE RAMIREZ - Planetary Defender on NASA's Double Asteroid Redirec...
 
GDSC ASEB Gen AI study jams presentation
GDSC ASEB Gen AI study jams presentationGDSC ASEB Gen AI study jams presentation
GDSC ASEB Gen AI study jams presentation
 
OSVC_Meta-Data based Simulation Automation to overcome Verification Challenge...
OSVC_Meta-Data based Simulation Automation to overcome Verification Challenge...OSVC_Meta-Data based Simulation Automation to overcome Verification Challenge...
OSVC_Meta-Data based Simulation Automation to overcome Verification Challenge...
 
Sheet Pile Wall Design and Construction: A Practical Guide for Civil Engineer...
Sheet Pile Wall Design and Construction: A Practical Guide for Civil Engineer...Sheet Pile Wall Design and Construction: A Practical Guide for Civil Engineer...
Sheet Pile Wall Design and Construction: A Practical Guide for Civil Engineer...
 
(MEERA) Dapodi Call Girls Just Call 7001035870 [ Cash on Delivery ] Pune Escorts
(MEERA) Dapodi Call Girls Just Call 7001035870 [ Cash on Delivery ] Pune Escorts(MEERA) Dapodi Call Girls Just Call 7001035870 [ Cash on Delivery ] Pune Escorts
(MEERA) Dapodi Call Girls Just Call 7001035870 [ Cash on Delivery ] Pune Escorts
 
Call Girls Narol 7397865700 Independent Call Girls
Call Girls Narol 7397865700 Independent Call GirlsCall Girls Narol 7397865700 Independent Call Girls
Call Girls Narol 7397865700 Independent Call Girls
 
9953056974 Call Girls In South Ex, Escorts (Delhi) NCR.pdf
9953056974 Call Girls In South Ex, Escorts (Delhi) NCR.pdf9953056974 Call Girls In South Ex, Escorts (Delhi) NCR.pdf
9953056974 Call Girls In South Ex, Escorts (Delhi) NCR.pdf
 
power system scada applications and uses
power system scada applications and usespower system scada applications and uses
power system scada applications and uses
 
Internship report on mechanical engineering
Internship report on mechanical engineeringInternship report on mechanical engineering
Internship report on mechanical engineering
 
chaitra-1.pptx fake news detection using machine learning
chaitra-1.pptx  fake news detection using machine learningchaitra-1.pptx  fake news detection using machine learning
chaitra-1.pptx fake news detection using machine learning
 
HARMONY IN THE HUMAN BEING - Unit-II UHV-2
HARMONY IN THE HUMAN BEING - Unit-II UHV-2HARMONY IN THE HUMAN BEING - Unit-II UHV-2
HARMONY IN THE HUMAN BEING - Unit-II UHV-2
 
VIP Call Girls Service Hitech City Hyderabad Call +91-8250192130
VIP Call Girls Service Hitech City Hyderabad Call +91-8250192130VIP Call Girls Service Hitech City Hyderabad Call +91-8250192130
VIP Call Girls Service Hitech City Hyderabad Call +91-8250192130
 
Microscopic Analysis of Ceramic Materials.pptx
Microscopic Analysis of Ceramic Materials.pptxMicroscopic Analysis of Ceramic Materials.pptx
Microscopic Analysis of Ceramic Materials.pptx
 
SPICE PARK APR2024 ( 6,793 SPICE Models )
SPICE PARK APR2024 ( 6,793 SPICE Models )SPICE PARK APR2024 ( 6,793 SPICE Models )
SPICE PARK APR2024 ( 6,793 SPICE Models )
 
Architect Hassan Khalil Portfolio for 2024
Architect Hassan Khalil Portfolio for 2024Architect Hassan Khalil Portfolio for 2024
Architect Hassan Khalil Portfolio for 2024
 
What are the advantages and disadvantages of membrane structures.pptx
What are the advantages and disadvantages of membrane structures.pptxWhat are the advantages and disadvantages of membrane structures.pptx
What are the advantages and disadvantages of membrane structures.pptx
 
Heart Disease Prediction using machine learning.pptx
Heart Disease Prediction using machine learning.pptxHeart Disease Prediction using machine learning.pptx
Heart Disease Prediction using machine learning.pptx
 
Gfe Mayur Vihar Call Girls Service WhatsApp -> 9999965857 Available 24x7 ^ De...
Gfe Mayur Vihar Call Girls Service WhatsApp -> 9999965857 Available 24x7 ^ De...Gfe Mayur Vihar Call Girls Service WhatsApp -> 9999965857 Available 24x7 ^ De...
Gfe Mayur Vihar Call Girls Service WhatsApp -> 9999965857 Available 24x7 ^ De...
 

Counting Principles and Pigeonhole Principle

  • 1. LECTURE 15 Chapter 5.1 Counting Prepared by Khairun Nahar,Assistant Professor, Department of CSE, Comilla University
  • 2. Basic Counting Principles We will present two basic counting principles, the product rule and the sum rule. Then we will show how they can be used to solve many different counting problems. THE PRODUCT RULE: Suppose that a procedure can be broken down into a sequence of two tasks. If there are 𝑛1 ways to do the first task and for each of these ways of doing the first task, there are 𝑛2 ways to do the second task, then there are 𝑛1𝑛2 ways to do the procedure. The product rule applies when a procedure is made up of separate tasks. Prepared by Khairun Nahar,Assistant Professor, Department of CSE, Comilla University
  • 3. Example-1 Prepared by Khairun Nahar,Assistant Professor, Department of CSE, Comilla University Example-2
  • 4. Example-3 Prepared by Khairun Nahar,Assistant Professor, Department of CSE, Comilla University Example-4
  • 5. Example-5 Prepared by Khairun Nahar,Assistant Professor, Department of CSE, Comilla University Example-6 How many functions are there from a set with m elements to a set with n elements?
  • 6. Example-7 Prepared by Khairun Nahar,Assistant Professor, Department of CSE, Comilla University
  • 7. N=5. n-k+1 way=5-3+1=3 M=n A1->n1 A2->n2 A3->n3 A4->n4 A4->n5 Prepared by Khairun Nahar,Assistant Professor, Department of CSE, Comilla University
  • 8. THE SUM RULE If a task can be done either in one of 𝑛1 ways or in one of 𝑛2 ways, where none of the set of 𝑛1 ways is the same as any of the set of 𝑛2 ways, then there are 𝑛1 + 𝑛2 ways to do the task. Example 11: Suppose that either a member of the mathematics faculty or a student who is a mathematics major is chosen as a representative to a university committee. How many different choices are there for this representative if there are 37members of the mathematics faculty and 83 mathematics majors and no one is both a faculty member and a student? Solution: There are 37 ways to choose a member of the mathematics faculty and there are 83 ways to choose a student who is a mathematics major. Choosing a member of the mathematics faculty is never the same as choosing a student who is a mathematics major because no one is both a faculty member and a student. By the sum rule it follows that there are 37 +83 = 120 possible ways to pick this representative. Prepared by Khairun Nahar,Assistant Professor, Department of CSE, Comilla University
  • 9. EXAMPLE 14 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? 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, 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. Prepared by Khairun Nahar,Assistant Professor, Department of CSE, Comilla University
  • 10. Assignment 1. There are 18 mathematics majors and 325 computer science majors at a college. a) How many ways are there to pick two representatives so that one is a mathematics major and the other is a computer science major? b) How many ways are there to pick one representative who is either a mathematics major or a computer science major? 2. An office building contains 27 floors and has 37 offices on each floor. How many offices are in the building? 3. A multiple-choice test contains 10 questions. There are four possible answers 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 questions on the test if the student can leave answers blank? Prepared by Khairun Nahar,Assistant Professor, Department of CSE, Comilla University
  • 11. 4. How many bit strings of length n , where n is a positive integer, start and end with 1s? 5. How many strings of eight English letters are there a) that contain no vowels, if letters can be repeated? b) that contain no vowels, if letters cannot be repeated? c) that start with a vowel, if letters can be repeated? d) that start with a vowel, if letters cannot be repeated? e) that contain at least one vowel, if letters can be repeated? f) that contain exactly one vowel, if letters can be repeated? g) that start with X and contain at least one vowel, if letters can be repeated? h) that start and end with X and contain at least one vowel, if letters can be repeated? Prepared by Khairun Nahar,Assistant Professor, Department of CSE, Comilla University
  • 12. a) How many strings of eight English letters are there that contain no vowels, if letters can be repeated? =>There are 5 vowels . Then any of 21 letters can appear in any of the 8 positions, so the answer is 218=37822859361 b) How many strings of eight English letters are there that contain no vowels, if letters cannot be repeated? =>The first can be any of 21 letters, the next can’t be the same as the first, so there are 20 possible letters, the third can be any of 19, etc. Therefore, the answer is 21×20×19×18×17×16×15×14 =8204716800 that is 21!/13! =8204716800 Prepared by Khairun Nahar,Assistant Professor, Department of CSE, Comilla University Solution of Problem (5)
  • 13. c) How many strings of eight English letters are there that start with a vowel, if letters can be repeated? => Since there are 5 possibilities for the first letter and 26 for each of the rest. That’s 5 · 267=40159050880 d) How many strings of eight English letters are there that start with a vowel, if letters cannot be repeated? =>There are 5 possibilities for the first letter, 25 for the second, 24 for the third, etc. That gives 5·25·24.23.22.21.20.19.18 =12113640000 or 5·25!/17!= 12113640000 e) How many strings of eight English letters are there that contain at least one vowel, if letters can be repeated? =>There are 268 strings in all, but only 218 that don’t have a vowel. Therefore, there are 268 − 218 =171004205215 that have at least one vowel. Prepared by Khairun Nahar,Assistant Professor, Department of CSE, Comilla University
  • 14. f) How many strings of eight English letters are there that that contain exactly one vowel, if letters can be repeated? The vowel (any of 5 possibilities) can occur in any of 8 places, and the other 7 places each can have any of 21 possible letters. That gives 5 · 8 · 217 = 72043541640 g) How many strings of eight English letters are there that that start with X and contain at least one vowel, if letters can be repeated? =>There are 267 strings that start with an X, and 217 that don’t have any vowel, so the answer is 267 − 217=6230721635. h) How many strings of eight English letters are there that that start and end with X and contain at least one vowel, if letters can be repeated? =>There are 266 strings that start and end with an X, and 216 of those that don’t have any vowel, so the answer is 266 − 216=223149655. Prepared by Khairun Nahar,Assistant Professor, Department of CSE, Comilla University
  • 15. Chapter 5.2 The Pigeonhole Principle Prepared by Khairun Nahar,Assistant Professor, Department of CSE, Comilla University
  • 16. THE PIGEONHOLE PRINCIPLE Prepared by Khairun Nahar,Assistant Professor, Department of CSE, Comilla University
  • 17. 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. Prepared by Khairun Nahar,Assistant Professor, Department of CSE, Comilla University
  • 18. THEOREM 2 THE GENERALIZED PIGEONHOLE PRINCIPLE If N objects are placed into k boxes, then there is at least one box containing at least ⌈ 𝑁 𝐾 ⌉objects. Proof: We will use a proof by contradiction. Suppose that none of the boxes contains more than ⌈ 𝑁 𝐾 ⌉- 1 objects. Then, the total number of objects is at most where the inequality ⌈ 𝑁 𝐾 ⌉ < ( 𝑁 𝐾 )+ 1 has been used. This is a contradiction because there are a total of N objects. Prepared by Khairun Nahar,Assistant Professor, Department of CSE, Comilla University N=6,k=5=> 5x(ceil(1.2)-1)< 5x ((1.2+1)-1); => 5x(2-1)< 5.2 But N=6
  • 19. Prepared by Khairun Nahar,Assistant Professor, Department of CSE, Comilla University
  • 20. Exercise-1: Show that in any set of six classes, each meeting regularly once a week on a particular day of the week, there must be two that meet on the same day, assuming that no classes are held on weekends. Solution: Here are six classes (pigeons), but only five weekdays (pigeonholes). Therefore, by the pigeonhole principle, at least (⌈ 6 5 ⌉ ) = 2 classes must be held on the same day. Exercise-2: Show that if there are 30 students in a class, then at least two have last names that begin with the same letter. Solution: We have 26 letters, and 30 students so using Pigeonhole Principle we have (⌈ 30 26 ⌉) = 2. Prepared by Khairun Nahar,Assistant Professor, Department of CSE, Comilla University
  • 21. Chapter 5.3 Permutations and Combinations Prepared by Khairun Nahar,Assistant Professor, Department of CSE, Comilla University
  • 22. Permutations A permutation of a set of distinct objects is an ordered arrangement of these objects. We also are interested in ordered arrangements of some of the elements of a set. The word "permutation" also refers to the act or process of changing the linear order of an ordered set. An ordered arrangement of r elements of a set is called an r-permutation. The number of r-permutations of a set with n elements is denoted by 𝑷(𝒏 , 𝒓). Example: Let S = {1 , 2, 3} . The ordered arrangement {3, 1, 2} is a permutation of S. The ordered arrangement {3, 2} is a 2- permutation of S. 3-permutation of S are: {1, 2, 3}, {1, 3, 2}, {2, 1, 3}, {2, 3, 1}, {3, 1, 2}, and {3, 2, 1}. Prepared by Khairun Nahar,Assistant Professor, Department of CSE, Comilla University
  • 23. Prepared by Khairun Nahar,Assistant Professor, Department of CSE, Comilla University
  • 24. Prepared by Khairun Nahar,Assistant Professor, Department of CSE, Comilla University
  • 25. Prepared by Khairun Nahar,Assistant Professor, Department of CSE, Comilla University
  • 26. Combinations The combination is a way of selecting items from a collection, such that (unlike permutations) the order of selection does not matter. An 𝑟 −combination of elements of a set is an unordered selection of r elements from the set. Thus, a 𝑟 −combination is simply a subset of the set with r elements. The number of r-combinations of a set with n distinct elements is denoted by 𝐶(𝑛, 𝑟 ). Note that 𝐶(𝑛 , 𝑟) is also denoted by (𝑛 𝑟 ) and is called a binomial coefficient. Prepared by Khairun Nahar,Assistant Professor, Department of CSE, Comilla University
  • 27. Prepared by Khairun Nahar,Assistant Professor, Department of CSE, Comilla University
  • 28. Permutation and Combination S1={a,b,c} S2={Saimon, Rahim, Karim} n=3 S1={a,b},{b,c},{c,a},{a,c},{b,a},{c,b}=6 way= permutation S2={Saimon,Rahim} =3 way= combination {Saimon, Karim} {Rahim,Karim} {Rahim, Saimon} {Karim, Saimon} {Karim, Rahim} Prepared by Khairun Nahar,Assistant Professor, Department of CSE, Comilla University
  • 29. Prepared by Khairun Nahar,Assistant Professor, Department of CSE, Comilla University
  • 30. Relation between Permutation and Combination P(n , r) = C (n, r)× r ! Permutation Formula Combination Formula Prepared by Khairun Nahar,Assistant Professor, Department of CSE, Comilla University