SlideShare a Scribd company logo
1 of 34
COUNTING
TAHSIN AZIZ
COMPUTER SCIENCE AND ENGINEERING
AHSANULLAH UNIVERSITY OF SCIENCE AND TECHNOLOGY
REFERENCE BOOK
DISCRETE MATHEMATICS AND ITS APPLICATIONS
BY KENNETH H. ROSEN
2Tahsin Aziz
BASIC COUNTING PRINCIPLES
• Two basic counting principles –
• The product rule
• The sum rule
3Tahsin Aziz
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
THE PRODUCT RULE
Task 1
N1 way
Task 2
N2 way
Procedure
N1 × N2
possible
ways
5Tahsin Aziz
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
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
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
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
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
THE SUM RULE
Task 1
N1 way
Task 1
N2 way
Procedure
N1 + N2
possible
ways
11Tahsin Aziz
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
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
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
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
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
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
INCLUSION-EXCLUSION PRINCIPLE
Set A Set B
Twice time
included
18Tahsin Aziz
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
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
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
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
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
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
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
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
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
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
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
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
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
COUNTABLE AND UNCOUNTABLE SETS
• Example
{1, 3, 5, 7, …………………..} = O
{0, 1, 2, 3, …………………..} = N
f: N 0 ; f(n) = 2n + 1
32Tahsin Aziz
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
THANK YOU ALL
34Tahsin Aziz

More Related Content

What's hot

Lecture slides stats1.13.l11.air
Lecture slides stats1.13.l11.airLecture slides stats1.13.l11.air
Lecture slides stats1.13.l11.airatutor_te
 
Introduction to Business Mathematics
Introduction to Business MathematicsIntroduction to Business Mathematics
Introduction to Business MathematicsZunair Bhatti
 
GREKing: The most repeated type of quants problem.
GREKing: The most repeated type of quants problem.GREKing: The most repeated type of quants problem.
GREKing: The most repeated type of quants problem.Rahul Singh
 
Business mathematics is a very powerful tools and analytic process that resul...
Business mathematics is a very powerful tools and analytic process that resul...Business mathematics is a very powerful tools and analytic process that resul...
Business mathematics is a very powerful tools and analytic process that resul...mkrony
 
Introduction of sequence
Introduction of sequenceIntroduction of sequence
Introduction of sequenceKARAN PANCHAL
 
Progression of outcomes for place value 1 (1)
Progression of outcomes for place value 1 (1)Progression of outcomes for place value 1 (1)
Progression of outcomes for place value 1 (1)susan70
 
Chapter 11 index number
Chapter 11  index numberChapter 11  index number
Chapter 11 index numberatiqah ayie
 
Application linear function
Application linear functionApplication linear function
Application linear functionpuspitaaya
 
(8) Lesson 3.8
(8) Lesson 3.8(8) Lesson 3.8
(8) Lesson 3.8wzuri
 

What's hot (15)

Number and operations review1
Number and operations review1Number and operations review1
Number and operations review1
 
Lecture slides stats1.13.l11.air
Lecture slides stats1.13.l11.airLecture slides stats1.13.l11.air
Lecture slides stats1.13.l11.air
 
Theory of Equation
Theory of EquationTheory of Equation
Theory of Equation
 
Introduction to Business Mathematics
Introduction to Business MathematicsIntroduction to Business Mathematics
Introduction to Business Mathematics
 
GREKing: The most repeated type of quants problem.
GREKing: The most repeated type of quants problem.GREKing: The most repeated type of quants problem.
GREKing: The most repeated type of quants problem.
 
Algebra and functions review
Algebra and functions reviewAlgebra and functions review
Algebra and functions review
 
Business mathematics is a very powerful tools and analytic process that resul...
Business mathematics is a very powerful tools and analytic process that resul...Business mathematics is a very powerful tools and analytic process that resul...
Business mathematics is a very powerful tools and analytic process that resul...
 
Algebra2 corollary
Algebra2   corollaryAlgebra2   corollary
Algebra2 corollary
 
Introduction of sequence
Introduction of sequenceIntroduction of sequence
Introduction of sequence
 
Progression of outcomes for place value 1 (1)
Progression of outcomes for place value 1 (1)Progression of outcomes for place value 1 (1)
Progression of outcomes for place value 1 (1)
 
Chapter 11 index number
Chapter 11  index numberChapter 11  index number
Chapter 11 index number
 
Chapter 6 - Matrix Algebra
Chapter 6 - Matrix AlgebraChapter 6 - Matrix Algebra
Chapter 6 - Matrix Algebra
 
Application linear function
Application linear functionApplication linear function
Application linear function
 
(8) Lesson 3.8
(8) Lesson 3.8(8) Lesson 3.8
(8) Lesson 3.8
 
Math Lesson 9
Math Lesson 9Math Lesson 9
Math Lesson 9
 

Similar to Counting

Finite mathematics
Finite mathematicsFinite mathematics
Finite mathematicsIgor Rivin
 
Nts and gat general book
Nts and gat general bookNts and gat general book
Nts and gat general bookYasar Hayat
 
Discrete Math Ch5 counting + proofs
Discrete Math Ch5 counting + proofsDiscrete Math Ch5 counting + proofs
Discrete Math Ch5 counting + proofsAmr Rashed
 
1. Permutation and Combination.pdfjskkshssh
1. Permutation and Combination.pdfjskkshssh1. Permutation and Combination.pdfjskkshssh
1. Permutation and Combination.pdfjskkshsshJayveeRouge
 
counting techniques
counting techniquescounting techniques
counting techniquesUnsa Shakir
 
Lecture_15_Chapter_5_Lesson_5.1 (1).pptx
Lecture_15_Chapter_5_Lesson_5.1 (1).pptxLecture_15_Chapter_5_Lesson_5.1 (1).pptx
Lecture_15_Chapter_5_Lesson_5.1 (1).pptxHomer53
 
Mathematics in the Modern World (Patterns and Sequences).pptx
Mathematics in the Modern World (Patterns and Sequences).pptxMathematics in the Modern World (Patterns and Sequences).pptx
Mathematics in the Modern World (Patterns and Sequences).pptxReignAnntonetteYayai
 
Lecture 1- DM Intro.pptx
Lecture 1- DM Intro.pptxLecture 1- DM Intro.pptx
Lecture 1- DM Intro.pptxRydaS1
 
G6 m4-g-lesson 26-t
G6 m4-g-lesson 26-tG6 m4-g-lesson 26-t
G6 m4-g-lesson 26-tmlabuski
 
Business mathematics presentation
Business mathematics presentationBusiness mathematics presentation
Business mathematics presentationSourov Shaha Suvo
 
bcfbedbf-6679-4d5d-b8a5-7d4c9c48dba4.pptx
bcfbedbf-6679-4d5d-b8a5-7d4c9c48dba4.pptxbcfbedbf-6679-4d5d-b8a5-7d4c9c48dba4.pptx
bcfbedbf-6679-4d5d-b8a5-7d4c9c48dba4.pptxB.T.L.I.T
 
Topic 3 Measures of Central Tendency -Grouped Data.pptx
Topic 3 Measures of Central Tendency -Grouped Data.pptxTopic 3 Measures of Central Tendency -Grouped Data.pptx
Topic 3 Measures of Central Tendency -Grouped Data.pptxCallplanetsDeveloper
 
MATH-9-Q1-M1-L4-PPT.pptx
MATH-9-Q1-M1-L4-PPT.pptxMATH-9-Q1-M1-L4-PPT.pptx
MATH-9-Q1-M1-L4-PPT.pptxMitziEngbino2
 
Minimization of Boolean Functions
Minimization of Boolean FunctionsMinimization of Boolean Functions
Minimization of Boolean Functionsblaircomp2003
 
Insider mathematical
Insider   mathematicalInsider   mathematical
Insider mathematicalAditi Saxena
 

Similar to Counting (20)

Combinatorics.ppt
Combinatorics.pptCombinatorics.ppt
Combinatorics.ppt
 
Topic 3 Grouped Data.pptx
Topic 3 Grouped Data.pptxTopic 3 Grouped Data.pptx
Topic 3 Grouped Data.pptx
 
Finite mathematics
Finite mathematicsFinite mathematics
Finite mathematics
 
Nts and gat general book
Nts and gat general bookNts and gat general book
Nts and gat general book
 
Discrete Math Ch5 counting + proofs
Discrete Math Ch5 counting + proofsDiscrete Math Ch5 counting + proofs
Discrete Math Ch5 counting + proofs
 
1. Permutation and Combination.pdfjskkshssh
1. Permutation and Combination.pdfjskkshssh1. Permutation and Combination.pdfjskkshssh
1. Permutation and Combination.pdfjskkshssh
 
counting techniques
counting techniquescounting techniques
counting techniques
 
Lecture_15_Chapter_5_Lesson_5.1 (1).pptx
Lecture_15_Chapter_5_Lesson_5.1 (1).pptxLecture_15_Chapter_5_Lesson_5.1 (1).pptx
Lecture_15_Chapter_5_Lesson_5.1 (1).pptx
 
Counting Theroy .pptx
Counting Theroy .pptxCounting Theroy .pptx
Counting Theroy .pptx
 
Mathematics in the Modern World (Patterns and Sequences).pptx
Mathematics in the Modern World (Patterns and Sequences).pptxMathematics in the Modern World (Patterns and Sequences).pptx
Mathematics in the Modern World (Patterns and Sequences).pptx
 
Lecture 1- DM Intro.pptx
Lecture 1- DM Intro.pptxLecture 1- DM Intro.pptx
Lecture 1- DM Intro.pptx
 
G6 m4-g-lesson 26-t
G6 m4-g-lesson 26-tG6 m4-g-lesson 26-t
G6 m4-g-lesson 26-t
 
Section3 2
Section3 2Section3 2
Section3 2
 
Business mathematics presentation
Business mathematics presentationBusiness mathematics presentation
Business mathematics presentation
 
bcfbedbf-6679-4d5d-b8a5-7d4c9c48dba4.pptx
bcfbedbf-6679-4d5d-b8a5-7d4c9c48dba4.pptxbcfbedbf-6679-4d5d-b8a5-7d4c9c48dba4.pptx
bcfbedbf-6679-4d5d-b8a5-7d4c9c48dba4.pptx
 
Topic 3 Measures of Central Tendency -Grouped Data.pptx
Topic 3 Measures of Central Tendency -Grouped Data.pptxTopic 3 Measures of Central Tendency -Grouped Data.pptx
Topic 3 Measures of Central Tendency -Grouped Data.pptx
 
MATH-9-Q1-M1-L4-PPT.pptx
MATH-9-Q1-M1-L4-PPT.pptxMATH-9-Q1-M1-L4-PPT.pptx
MATH-9-Q1-M1-L4-PPT.pptx
 
Minimization of Boolean Functions
Minimization of Boolean FunctionsMinimization of Boolean Functions
Minimization of Boolean Functions
 
Algebra i
Algebra iAlgebra i
Algebra i
 
Insider mathematical
Insider   mathematicalInsider   mathematical
Insider mathematical
 

Recently uploaded

CELL CYCLE Division Science 8 quarter IV.pptx
CELL CYCLE Division Science 8 quarter IV.pptxCELL CYCLE Division Science 8 quarter IV.pptx
CELL CYCLE Division Science 8 quarter IV.pptxJiesonDelaCerna
 
Interactive Powerpoint_How to Master effective communication
Interactive Powerpoint_How to Master effective communicationInteractive Powerpoint_How to Master effective communication
Interactive Powerpoint_How to Master effective communicationnomboosow
 
Earth Day Presentation wow hello nice great
Earth Day Presentation wow hello nice greatEarth Day Presentation wow hello nice great
Earth Day Presentation wow hello nice greatYousafMalik24
 
Incoming and Outgoing Shipments in 1 STEP Using Odoo 17
Incoming and Outgoing Shipments in 1 STEP Using Odoo 17Incoming and Outgoing Shipments in 1 STEP Using Odoo 17
Incoming and Outgoing Shipments in 1 STEP Using Odoo 17Celine George
 
18-04-UA_REPORT_MEDIALITERAСY_INDEX-DM_23-1-final-eng.pdf
18-04-UA_REPORT_MEDIALITERAСY_INDEX-DM_23-1-final-eng.pdf18-04-UA_REPORT_MEDIALITERAСY_INDEX-DM_23-1-final-eng.pdf
18-04-UA_REPORT_MEDIALITERAСY_INDEX-DM_23-1-final-eng.pdfssuser54595a
 
History Class XII Ch. 3 Kinship, Caste and Class (1).pptx
History Class XII Ch. 3 Kinship, Caste and Class (1).pptxHistory Class XII Ch. 3 Kinship, Caste and Class (1).pptx
History Class XII Ch. 3 Kinship, Caste and Class (1).pptxsocialsciencegdgrohi
 
POINT- BIOCHEMISTRY SEM 2 ENZYMES UNIT 5.pptx
POINT- BIOCHEMISTRY SEM 2 ENZYMES UNIT 5.pptxPOINT- BIOCHEMISTRY SEM 2 ENZYMES UNIT 5.pptx
POINT- BIOCHEMISTRY SEM 2 ENZYMES UNIT 5.pptxSayali Powar
 
CARE OF CHILD IN INCUBATOR..........pptx
CARE OF CHILD IN INCUBATOR..........pptxCARE OF CHILD IN INCUBATOR..........pptx
CARE OF CHILD IN INCUBATOR..........pptxGaneshChakor2
 
Meghan Sutherland In Media Res Media Component
Meghan Sutherland In Media Res Media ComponentMeghan Sutherland In Media Res Media Component
Meghan Sutherland In Media Res Media ComponentInMediaRes1
 
ECONOMIC CONTEXT - LONG FORM TV DRAMA - PPT
ECONOMIC CONTEXT - LONG FORM TV DRAMA - PPTECONOMIC CONTEXT - LONG FORM TV DRAMA - PPT
ECONOMIC CONTEXT - LONG FORM TV DRAMA - PPTiammrhaywood
 
Solving Puzzles Benefits Everyone (English).pptx
Solving Puzzles Benefits Everyone (English).pptxSolving Puzzles Benefits Everyone (English).pptx
Solving Puzzles Benefits Everyone (English).pptxOH TEIK BIN
 
Introduction to ArtificiaI Intelligence in Higher Education
Introduction to ArtificiaI Intelligence in Higher EducationIntroduction to ArtificiaI Intelligence in Higher Education
Introduction to ArtificiaI Intelligence in Higher Educationpboyjonauth
 
Employee wellbeing at the workplace.pptx
Employee wellbeing at the workplace.pptxEmployee wellbeing at the workplace.pptx
Employee wellbeing at the workplace.pptxNirmalaLoungPoorunde1
 
Alper Gobel In Media Res Media Component
Alper Gobel In Media Res Media ComponentAlper Gobel In Media Res Media Component
Alper Gobel In Media Res Media ComponentInMediaRes1
 
“Oh GOSH! Reflecting on Hackteria's Collaborative Practices in a Global Do-It...
“Oh GOSH! Reflecting on Hackteria's Collaborative Practices in a Global Do-It...“Oh GOSH! Reflecting on Hackteria's Collaborative Practices in a Global Do-It...
“Oh GOSH! Reflecting on Hackteria's Collaborative Practices in a Global Do-It...Marc Dusseiller Dusjagr
 
Historical philosophical, theoretical, and legal foundations of special and i...
Historical philosophical, theoretical, and legal foundations of special and i...Historical philosophical, theoretical, and legal foundations of special and i...
Historical philosophical, theoretical, and legal foundations of special and i...jaredbarbolino94
 
Types of Journalistic Writing Grade 8.pptx
Types of Journalistic Writing Grade 8.pptxTypes of Journalistic Writing Grade 8.pptx
Types of Journalistic Writing Grade 8.pptxEyham Joco
 
Hierarchy of management that covers different levels of management
Hierarchy of management that covers different levels of managementHierarchy of management that covers different levels of management
Hierarchy of management that covers different levels of managementmkooblal
 
Framing an Appropriate Research Question 6b9b26d93da94caf993c038d9efcdedb.pdf
Framing an Appropriate Research Question 6b9b26d93da94caf993c038d9efcdedb.pdfFraming an Appropriate Research Question 6b9b26d93da94caf993c038d9efcdedb.pdf
Framing an Appropriate Research Question 6b9b26d93da94caf993c038d9efcdedb.pdfUjwalaBharambe
 

Recently uploaded (20)

CELL CYCLE Division Science 8 quarter IV.pptx
CELL CYCLE Division Science 8 quarter IV.pptxCELL CYCLE Division Science 8 quarter IV.pptx
CELL CYCLE Division Science 8 quarter IV.pptx
 
Interactive Powerpoint_How to Master effective communication
Interactive Powerpoint_How to Master effective communicationInteractive Powerpoint_How to Master effective communication
Interactive Powerpoint_How to Master effective communication
 
Earth Day Presentation wow hello nice great
Earth Day Presentation wow hello nice greatEarth Day Presentation wow hello nice great
Earth Day Presentation wow hello nice great
 
Incoming and Outgoing Shipments in 1 STEP Using Odoo 17
Incoming and Outgoing Shipments in 1 STEP Using Odoo 17Incoming and Outgoing Shipments in 1 STEP Using Odoo 17
Incoming and Outgoing Shipments in 1 STEP Using Odoo 17
 
18-04-UA_REPORT_MEDIALITERAСY_INDEX-DM_23-1-final-eng.pdf
18-04-UA_REPORT_MEDIALITERAСY_INDEX-DM_23-1-final-eng.pdf18-04-UA_REPORT_MEDIALITERAСY_INDEX-DM_23-1-final-eng.pdf
18-04-UA_REPORT_MEDIALITERAСY_INDEX-DM_23-1-final-eng.pdf
 
Model Call Girl in Bikash Puri Delhi reach out to us at 🔝9953056974🔝
Model Call Girl in Bikash Puri  Delhi reach out to us at 🔝9953056974🔝Model Call Girl in Bikash Puri  Delhi reach out to us at 🔝9953056974🔝
Model Call Girl in Bikash Puri Delhi reach out to us at 🔝9953056974🔝
 
History Class XII Ch. 3 Kinship, Caste and Class (1).pptx
History Class XII Ch. 3 Kinship, Caste and Class (1).pptxHistory Class XII Ch. 3 Kinship, Caste and Class (1).pptx
History Class XII Ch. 3 Kinship, Caste and Class (1).pptx
 
POINT- BIOCHEMISTRY SEM 2 ENZYMES UNIT 5.pptx
POINT- BIOCHEMISTRY SEM 2 ENZYMES UNIT 5.pptxPOINT- BIOCHEMISTRY SEM 2 ENZYMES UNIT 5.pptx
POINT- BIOCHEMISTRY SEM 2 ENZYMES UNIT 5.pptx
 
CARE OF CHILD IN INCUBATOR..........pptx
CARE OF CHILD IN INCUBATOR..........pptxCARE OF CHILD IN INCUBATOR..........pptx
CARE OF CHILD IN INCUBATOR..........pptx
 
Meghan Sutherland In Media Res Media Component
Meghan Sutherland In Media Res Media ComponentMeghan Sutherland In Media Res Media Component
Meghan Sutherland In Media Res Media Component
 
ECONOMIC CONTEXT - LONG FORM TV DRAMA - PPT
ECONOMIC CONTEXT - LONG FORM TV DRAMA - PPTECONOMIC CONTEXT - LONG FORM TV DRAMA - PPT
ECONOMIC CONTEXT - LONG FORM TV DRAMA - PPT
 
Solving Puzzles Benefits Everyone (English).pptx
Solving Puzzles Benefits Everyone (English).pptxSolving Puzzles Benefits Everyone (English).pptx
Solving Puzzles Benefits Everyone (English).pptx
 
Introduction to ArtificiaI Intelligence in Higher Education
Introduction to ArtificiaI Intelligence in Higher EducationIntroduction to ArtificiaI Intelligence in Higher Education
Introduction to ArtificiaI Intelligence in Higher Education
 
Employee wellbeing at the workplace.pptx
Employee wellbeing at the workplace.pptxEmployee wellbeing at the workplace.pptx
Employee wellbeing at the workplace.pptx
 
Alper Gobel In Media Res Media Component
Alper Gobel In Media Res Media ComponentAlper Gobel In Media Res Media Component
Alper Gobel In Media Res Media Component
 
“Oh GOSH! Reflecting on Hackteria's Collaborative Practices in a Global Do-It...
“Oh GOSH! Reflecting on Hackteria's Collaborative Practices in a Global Do-It...“Oh GOSH! Reflecting on Hackteria's Collaborative Practices in a Global Do-It...
“Oh GOSH! Reflecting on Hackteria's Collaborative Practices in a Global Do-It...
 
Historical philosophical, theoretical, and legal foundations of special and i...
Historical philosophical, theoretical, and legal foundations of special and i...Historical philosophical, theoretical, and legal foundations of special and i...
Historical philosophical, theoretical, and legal foundations of special and i...
 
Types of Journalistic Writing Grade 8.pptx
Types of Journalistic Writing Grade 8.pptxTypes of Journalistic Writing Grade 8.pptx
Types of Journalistic Writing Grade 8.pptx
 
Hierarchy of management that covers different levels of management
Hierarchy of management that covers different levels of managementHierarchy of management that covers different levels of management
Hierarchy of management that covers different levels of management
 
Framing an Appropriate Research Question 6b9b26d93da94caf993c038d9efcdedb.pdf
Framing an Appropriate Research Question 6b9b26d93da94caf993c038d9efcdedb.pdfFraming an Appropriate Research Question 6b9b26d93da94caf993c038d9efcdedb.pdf
Framing an Appropriate Research Question 6b9b26d93da94caf993c038d9efcdedb.pdf
 

Counting

  • 1. COUNTING TAHSIN AZIZ COMPUTER SCIENCE AND ENGINEERING AHSANULLAH UNIVERSITY OF SCIENCE AND TECHNOLOGY
  • 2. REFERENCE BOOK DISCRETE MATHEMATICS AND ITS APPLICATIONS BY KENNETH H. ROSEN 2Tahsin Aziz
  • 3. BASIC COUNTING PRINCIPLES • Two basic counting principles – • The product rule • The sum rule 3Tahsin Aziz
  • 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
  • 18. INCLUSION-EXCLUSION PRINCIPLE Set A Set B Twice time included 18Tahsin 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