SlideShare a Scribd company logo
1 of 34
Fall 2002 CMSC 203 - Discrete 1
One, two, three, we’re…One, two, three, we’re…
CountingCounting
Fall 2002 CMSC 203 - Discrete 2
Basic Counting PrinciplesBasic Counting Principles
Counting problemsCounting problems are of the following kind:are of the following kind:
““How manyHow many different 8-letter passwords aredifferent 8-letter passwords are
there?”there?”
““How manyHow many possible ways are there to pick 11possible ways are there to pick 11
soccer players out of a 20-player team?”soccer players out of a 20-player team?”
Most importantly, counting is the basis forMost importantly, counting is the basis for
computingcomputing probabilities of discrete eventsprobabilities of discrete events..
(“What is the probability of winning the lottery?”)(“What is the probability of winning the lottery?”)
Fall 2002 CMSC 203 - Discrete 3
Basic Counting PrinciplesBasic Counting Principles
The sum rule:The sum rule:
If a task can be done in nIf a task can be done in n11 ways and a second taskways and a second task
in nin n22 ways, and if these two tasks cannot be doneways, and if these two tasks cannot be done
at the same time, then there are nat the same time, then there are n11 + n+ n22 ways to doways to do
either task.either task.
Example:Example:
The department will award a free computer toThe department will award a free computer to
either a CS student or a CS professor.either a CS student or a CS professor.
How many different choices are there, if thereHow many different choices are there, if there
are 530 students and 15 professors?are 530 students and 15 professors?
There are 530 + 15 = 545 choices.There are 530 + 15 = 545 choices.
Fall 2002 CMSC 203 - Discrete 4
Basic Counting PrinciplesBasic Counting Principles
Generalized sum rule:Generalized sum rule:
If we have tasks TIf we have tasks T11, T, T22, …, T, …, Tmm that can be done inthat can be done in
nn11, n, n22, …, n, …, nmm ways, respectively, and no two of theseways, respectively, and no two of these
tasks can be done at the same time, then theretasks can be done at the same time, then there
are nare n11 + n+ n22 + … + n+ … + nmm ways to do one of these tasks.ways to do one of these tasks.
Fall 2002 CMSC 203 - Discrete 5
Basic Counting PrinciplesBasic Counting Principles
The product rule:The product rule:
Suppose that a procedure can be broken downSuppose that a procedure can be broken down
into two successive tasks. If there are ninto two successive tasks. If there are n11 ways toways to
do the first task and ndo the first task and n22 ways to do the secondways to do the second
task after the first task has been done, thentask after the first task has been done, then
there are nthere are n11nn22 ways to do the procedure.ways to do the procedure.
Fall 2002 CMSC 203 - Discrete 6
Basic Counting PrinciplesBasic Counting Principles
Example:Example:
How many different license plates are there thatHow many different license plates are there that
containing exactly three English letters ?containing exactly three English letters ?
Solution:Solution:
There are 26 possibilities to pick the first letter,There are 26 possibilities to pick the first letter,
then 26 possibilities for the second one, and 26then 26 possibilities for the second one, and 26
for the last one.for the last one.
So there are 26So there are 26⋅⋅2626⋅⋅26 = 17576 different license26 = 17576 different license
plates.plates.
Fall 2002 CMSC 203 - Discrete 7
Basic Counting PrinciplesBasic Counting Principles
Generalized product rule:Generalized product rule:
If we have a procedure consisting of sequentialIf we have a procedure consisting of sequential
tasks Ttasks T11, T, T22, …, T, …, Tmm that can be done in nthat can be done in n11, n, n22, …, n, …, nmm
ways, respectively, then there are nways, respectively, then there are n11 ⋅⋅ nn22 ⋅⋅ …… ⋅⋅ nnmm
ways to carry out the procedure.ways to carry out the procedure.
Fall 2002 CMSC 203 - Discrete 8
Basic Counting PrinciplesBasic Counting Principles
The sum and product rules can also be phrased inThe sum and product rules can also be phrased in
terms ofterms of set theoryset theory..
Sum rule:Sum rule: Let ALet A11, A, A22, …, A, …, Amm be disjoint sets. Thenbe disjoint sets. Then
the number of ways to choose any element fromthe number of ways to choose any element from
one of these sets is |Aone of these sets is |A11 ∪∪ AA22 ∪∪ …… ∪∪ AAmm | =| =
|A|A11| + |A| + |A22| + … + |A| + … + |Amm|.|.
Product rule:Product rule: Let ALet A11, A, A22, …, A, …, Amm be finite sets. Thenbe finite sets. Then
the number of ways to choose one element fromthe number of ways to choose one element from
each set in the order Aeach set in the order A11, A, A22, …, A, …, Amm isis
|A|A11 ×× AA22 ×× …… ×× AAmm | = |A| = |A11|| ⋅⋅ |A|A22|| ⋅⋅ …… ⋅⋅ |A|Amm|.|.
Fall 2002 CMSC 203 - Discrete 9
Inclusion-ExclusionInclusion-Exclusion
How many bit strings of length 8 either start with aHow many bit strings of length 8 either start with a
1 or end with 00?1 or end with 00?
Task 1:Task 1: Construct a string of length 8 that startsConstruct a string of length 8 that starts
with a 1.with a 1.
There is one way to pick the first bit (1),There is one way to pick the first bit (1),
two ways to pick the second bit (0 or 1),two ways to pick the second bit (0 or 1),
two ways to pick the third bit (0 or 1),two ways to pick the third bit (0 or 1),
..
..
..
two ways to pick the eighth bit (0 or 1).two ways to pick the eighth bit (0 or 1).
Product rule:Product rule: Task 1 can be done in 1Task 1 can be done in 1⋅⋅2277
= 128 ways.= 128 ways.
Fall 2002 CMSC 203 - Discrete 10
Inclusion-ExclusionInclusion-Exclusion
Task 2:Task 2: Construct a string of length 8 that endsConstruct a string of length 8 that ends
with 00.with 00.
There are two ways to pick the first bit (0 or 1),There are two ways to pick the first bit (0 or 1),
two ways to pick the second bit (0 or 1),two ways to pick the second bit (0 or 1),
..
..
..
two ways to pick the sixth bit (0 or 1),two ways to pick the sixth bit (0 or 1),
one way to pick the seventh bit (0), andone way to pick the seventh bit (0), and
one way to pick the eighth bit (0).one way to pick the eighth bit (0).
Product rule:Product rule: Task 2 can be done in 2Task 2 can be done in 266
= 64 ways.= 64 ways.
Fall 2002 CMSC 203 - Discrete 11
Inclusion-ExclusionInclusion-Exclusion
Since there are 128 ways to do Task 1 and 64 waysSince there are 128 ways to do Task 1 and 64 ways
to do Task 2, does this mean that there are 192 bitto do Task 2, does this mean that there are 192 bit
strings either starting with 1 or ending with 00 ?strings either starting with 1 or ending with 00 ?
No, because here Task 1 and Task 2 can be doneNo, because here Task 1 and Task 2 can be done atat
the same timethe same time..
When we carry out Task 1 and create stringsWhen we carry out Task 1 and create strings
starting with 1, some of these strings end with 00.starting with 1, some of these strings end with 00.
Therefore, we sometimes do Tasks 1 and 2 at theTherefore, we sometimes do Tasks 1 and 2 at the
same time, sosame time, so the sum rule does not applythe sum rule does not apply..
Fall 2002 CMSC 203 - Discrete 12
Inclusion-ExclusionInclusion-Exclusion
If we want to use the sum rule in such a case, weIf we want to use the sum rule in such a case, we
have to subtract the cases when Tasks 1 and 2 arehave to subtract the cases when Tasks 1 and 2 are
done at the same time.done at the same time.
How many cases are there, that is, how manyHow many cases are there, that is, how many
strings start with 1strings start with 1 andand end with 00?end with 00?
There is one way to pick the first bit (1),There is one way to pick the first bit (1),
two ways for the second, …, sixth bit (0 or 1),two ways for the second, …, sixth bit (0 or 1),
one way for the seventh, eighth bit (0).one way for the seventh, eighth bit (0).
Product rule:Product rule: In 2In 255
= 32 cases, Tasks 1 and 2 are= 32 cases, Tasks 1 and 2 are
carried out at the same time.carried out at the same time.
Fall 2002 CMSC 203 - Discrete 13
Inclusion-ExclusionInclusion-Exclusion
Since there are 128 ways to complete Task 1 andSince there are 128 ways to complete Task 1 and
64 ways to complete Task 2, and in 32 of these64 ways to complete Task 2, and in 32 of these
cases Tasks 1 and 2 are completed at the samecases Tasks 1 and 2 are completed at the same
time, there aretime, there are
128 + 64 – 32 = 160 ways to do either task.128 + 64 – 32 = 160 ways to do either task.
In set theory, this corresponds to sets AIn set theory, this corresponds to sets A11 and Aand A22
that arethat are notnot disjoint. Then we have:disjoint. Then we have:
|A|A11 ∪∪ AA22| = |A| = |A11| + |A| + |A22| - |A| - |A11 ∩∩ AA22||
This is called theThis is called the principle of inclusion-exclusion.principle of inclusion-exclusion.
Fall 2002 CMSC 203 - Discrete 14
Tree DiagramsTree Diagrams
How many bit strings of length four do not haveHow many bit strings of length four do not have
two consecutive 1s?two consecutive 1s?
Task 1Task 1 Task 2Task 2 Task 3Task 3 Task 4Task 4
(1(1stst
bit)bit) (2(2ndnd
bit)bit) (3(3rdrd
bit)bit) (4(4thth
bit)bit)
00
00
00
00
11
11
00
11 00 00
11
11 00
00 00
11
11
00
There are 8 strings.There are 8 strings.
Fall 2002 CMSC 203 - Discrete 15
The Pigeonhole PrincipleThe Pigeonhole Principle
The pigeonhole principle:The pigeonhole principle: If (k + 1) or moreIf (k + 1) or more
objects are placed into k boxes, then there isobjects are placed into k boxes, then there is atat
leastleast one box containing two or more of theone box containing two or more of the
objects.objects.
Example 1:Example 1: If there are 11 players in a soccerIf there are 11 players in a soccer
team that wins 12-0, there must be at least oneteam that wins 12-0, there must be at least one
player in the team who scored at least twice.player in the team who scored at least twice.
Example 2:Example 2: If you have 6 classes from Monday toIf you have 6 classes from Monday to
Friday, there must be at least one day on which youFriday, there must be at least one day on which you
have at least two classes.have at least two classes.
Fall 2002 CMSC 203 - Discrete 16
The Pigeonhole PrincipleThe Pigeonhole Principle
The generalized pigeonhole principle:The generalized pigeonhole principle: If NIf N
objects are placed into k boxes, then there isobjects are placed into k boxes, then there is atat
leastleast one box containing at leastone box containing at least N/kN/k of theof the
objects.objects.
Example 1:Example 1: In our 60-student class, at least 12In our 60-student class, at least 12
students will get the same letter grade (A, B, C, D,students will get the same letter grade (A, B, C, D,
or F).or F).
Fall 2002 CMSC 203 - Discrete 17
The Pigeonhole PrincipleThe Pigeonhole Principle
Example 2:Example 2: Assume you have a drawer containing aAssume you have a drawer containing a
random distribution of a dozen brown socks and arandom distribution of a dozen brown socks and a
dozen black socks. It is dark, so how many socks dodozen black socks. It is dark, so how many socks do
you have to pick to be sure that among them thereyou have to pick to be sure that among them there
is a matching pair?is a matching pair?
There are two types of socks, so if you pick atThere are two types of socks, so if you pick at
least 3 socks, there must be either at least twoleast 3 socks, there must be either at least two
brown socks or at least two black socks.brown socks or at least two black socks.
Generalized pigeonhole principle:Generalized pigeonhole principle: 3/23/2 = 2.= 2.
Fall 2002 CMSC 203 - Discrete 18
Permutations and CombinationsPermutations and Combinations
How many ways are there to pick a set of 3 peopleHow many ways are there to pick a set of 3 people
from a group of 6?from a group of 6?
There are 6 choices for the first person, 5 for theThere are 6 choices for the first person, 5 for the
second one, and 4 for the third one, so there aresecond one, and 4 for the third one, so there are
66⋅⋅55⋅⋅4 = 120 ways to do this.4 = 120 ways to do this.
This is not the correct result!This is not the correct result!
For example, picking person C, then person A, andFor example, picking person C, then person A, and
then person E leads to thethen person E leads to the same groupsame group as firstas first
picking E, then C, and then A.picking E, then C, and then A.
However, these cases are countedHowever, these cases are counted separatelyseparately inin
the above equation.the above equation.
Fall 2002 CMSC 203 - Discrete 19
Permutations and CombinationsPermutations and Combinations
So how can we compute how many differentSo how can we compute how many different
subsets of people can be picked (that is, we want tosubsets of people can be picked (that is, we want to
disregard the order of picking) ?disregard the order of picking) ?
To find out about this, we need to look atTo find out about this, we need to look at
permutations.permutations.
AA permutationpermutation of a set of distinct objects is anof a set of distinct objects is an
ordered arrangement of these objects.ordered arrangement of these objects.
An ordered arrangement of r elements of a set isAn ordered arrangement of r elements of a set is
called ancalled an r-permutationr-permutation..
Fall 2002 CMSC 203 - Discrete 20
Permutations and CombinationsPermutations and Combinations
Example:Example: Let S = {1, 2, 3}.Let S = {1, 2, 3}.
The arrangement 3, 1, 2 is a permutation of S.The arrangement 3, 1, 2 is a permutation of S.
The arrangement 3, 2 is a 2-permutation of S.The arrangement 3, 2 is a 2-permutation of S.
The number of r-permutations of a set with nThe number of r-permutations of a set with n
distinct elements is denoted bydistinct elements is denoted by P(n, r).P(n, r).
We can calculate P(n, r) with the product rule:We can calculate P(n, r) with the product rule:
P(n, r) = nP(n, r) = n⋅⋅(n – 1)(n – 1)⋅⋅(n – 2)(n – 2) ⋅⋅……⋅⋅(n – r + 1).(n – r + 1).
(n choices for the first element, (n – 1) for the(n choices for the first element, (n – 1) for the
second one, (n – 2) for the third one…)second one, (n – 2) for the third one…)
Fall 2002 CMSC 203 - Discrete 21
Permutations and CombinationsPermutations and Combinations
Example:Example:
P(8, 3) = 8P(8, 3) = 8⋅⋅77⋅⋅6 = 3366 = 336
= (8= (8⋅⋅77⋅⋅66⋅⋅55⋅⋅44⋅⋅33⋅⋅22⋅⋅1)/(51)/(5⋅⋅44⋅⋅33⋅⋅22⋅⋅1)1)
General formula:General formula:
P(n, r) = n!/(n – r)!P(n, r) = n!/(n – r)!
Knowing this, we can return to our initial question:Knowing this, we can return to our initial question:
How many ways are there to pick a set of 3 peopleHow many ways are there to pick a set of 3 people
from a group of 6 (disregarding the order offrom a group of 6 (disregarding the order of
picking)?picking)?
Fall 2002 CMSC 203 - Discrete 22
Permutations and CombinationsPermutations and Combinations
AnAn r-combinationr-combination of elements of a set is anof elements of a set is an
unordered selection of r elements from the set.unordered selection of r elements from the set.
Thus, an r-combination is simply a subset of the setThus, an r-combination is simply a subset of the set
with r elements.with r elements.
Example:Example: Let S = {1, 2, 3, 4}.Let S = {1, 2, 3, 4}.
Then {1, 3, 4} is a 3-combination from S.Then {1, 3, 4} is a 3-combination from S.
The number of r-combinations of a set with nThe number of r-combinations of a set with n
distinct elements is denoted by C(n, r).distinct elements is denoted by C(n, r).
Example:Example: C(4, 2) = 6, since, for example, the 2-C(4, 2) = 6, since, for example, the 2-
combinations of a set {1, 2, 3, 4} are {1, 2}, {1, 3}, {1,combinations of a set {1, 2, 3, 4} are {1, 2}, {1, 3}, {1,
4}, {2, 3}, {2, 4}, {3, 4}.4}, {2, 3}, {2, 4}, {3, 4}.
Fall 2002 CMSC 203 - Discrete 23
Permutations and CombinationsPermutations and Combinations
How can we calculate C(n, r)?How can we calculate C(n, r)?
Consider that we can obtain the r-permutation of aConsider that we can obtain the r-permutation of a
set in the following way:set in the following way:
First,First, we form all the r-combinations of the setwe form all the r-combinations of the set
(there are C(n, r) such r-combinations).(there are C(n, r) such r-combinations).
Then,Then, we generate all possible orderings in each ofwe generate all possible orderings in each of
these r-combinations (there are P(r, r) suchthese r-combinations (there are P(r, r) such
orderings in each case).orderings in each case).
Therefore, we have:Therefore, we have:
P(n, r) = C(n, r)P(n, r) = C(n, r)⋅⋅P(r, r)P(r, r)
Fall 2002 CMSC 203 - Discrete 24
Permutations and CombinationsPermutations and Combinations
C(n, r) = P(n, r)/P(r, r)C(n, r) = P(n, r)/P(r, r)
= n!/(n – r)!/(r!/(r – r)!)= n!/(n – r)!/(r!/(r – r)!)
= n!/(r!(n – r)!)= n!/(r!(n – r)!)
Now we can answer our initial question:Now we can answer our initial question:
How many ways are there to pick a set of 3 peopleHow many ways are there to pick a set of 3 people
from a group of 6 (disregarding the order offrom a group of 6 (disregarding the order of
picking)?picking)?
C(6, 3) = 6!/(3!C(6, 3) = 6!/(3!⋅⋅3!) = 720/(63!) = 720/(6⋅⋅6) = 720/36 = 206) = 720/36 = 20
There are 20 different ways, that is, 20 differentThere are 20 different ways, that is, 20 different
groups to be picked.groups to be picked.
Fall 2002 CMSC 203 - Discrete 25
Permutations and CombinationsPermutations and Combinations
Corollary:Corollary:
Let n and r be nonnegative integers with rLet n and r be nonnegative integers with r ≤≤ n.n.
Then C(n, r) = C(n, n – r).Then C(n, r) = C(n, n – r).
Note thatNote that “picking a group of r people from a“picking a group of r people from a
group of n people”group of n people” is the same asis the same as “splitting a group“splitting a group
of n people into a group of r people and anotherof n people into a group of r people and another
group of (n – r) people”.group of (n – r) people”.
Please also look at proof on page 323.Please also look at proof on page 323.
Fall 2002 CMSC 203 - Discrete 26
Permutations and CombinationsPermutations and Combinations
Example:
A soccer club has 8 female and 7 male members.
For today’s match, the coach wants to have 6
female and 5 male players on the grass. How many
possible configurations are there?
C(8, 6) ⋅⋅ C(7, 5) = 8!/(6!C(7, 5) = 8!/(6!⋅⋅2!)2!) ⋅⋅ 7!/(5!7!/(5!⋅⋅2!)2!)
= 28= 28⋅⋅2121
= 588= 588
Fall 2002 CMSC 203 - Discrete 27
CombinationsCombinations
We also saw the following:We also saw the following:
),(
!)!(
!
)]!([)!(
!
),( rnC
rrn
n
rnnrn
n
rnnC =
−
=
−−−
=−
This symmetry is intuitively plausible. For example,This symmetry is intuitively plausible. For example,
let us consider a set containing six elements (n = 6).let us consider a set containing six elements (n = 6).
Picking twoPicking two elements andelements and leaving fourleaving four is essentiallyis essentially
the same asthe same as picking fourpicking four elements andelements and leaving twoleaving two..
In either case, our number of choices is theIn either case, our number of choices is the
number of possibilities tonumber of possibilities to dividedivide the set into onethe set into one
set containing two elements and another setset containing two elements and another set
containing four elements.containing four elements.
Fall 2002 CMSC 203 - Discrete 28
CombinationsCombinations
Pascal’s Identity:Pascal’s Identity:
Let n and k be positive integers with nLet n and k be positive integers with n ≥≥ k.k.
Then C(n + 1, k) = C(n, k – 1) + C(n, k).Then C(n + 1, k) = C(n, k – 1) + C(n, k).
How can this be explained?How can this be explained?
What is it good for?What is it good for?
Fall 2002 CMSC 203 - Discrete 29
CombinationsCombinations
Imagine a set S containing n elements and a set TImagine a set S containing n elements and a set T
containing (n + 1) elements, namely all elements incontaining (n + 1) elements, namely all elements in
S plus a new elementS plus a new element aa..
Calculating C(n + 1, k) is equivalent to answeringCalculating C(n + 1, k) is equivalent to answering
the question: How many subsets of T containing kthe question: How many subsets of T containing k
items are there?items are there?
Case I:Case I: The subset contains (k – 1) elements of SThe subset contains (k – 1) elements of S
plus the elementplus the element aa: C(n, k – 1) choices.: C(n, k – 1) choices.
Case II:Case II: The subset contains k elements of S andThe subset contains k elements of S and
does not containdoes not contain aa: C(n, k) choices.: C(n, k) choices.
Sum Rule:Sum Rule: C(n + 1, k) = C(n, k – 1) + C(n, k).C(n + 1, k) = C(n, k – 1) + C(n, k).
Fall 2002 CMSC 203 - Discrete 30
Pascal’s TrianglePascal’s Triangle
In Pascal’s triangle, each number is the sum ofIn Pascal’s triangle, each number is the sum of
the numbers to its upper left and upper right:the numbers to its upper left and upper right:
11
11 11
11 22 11
11 33 33 11
11 44 66 44 11
…… …… …… …… …… ……
Fall 2002 CMSC 203 - Discrete 31
Pascal’s TrianglePascal’s Triangle
Since we have C(n + 1, k) = C(n, k – 1) + C(n, k) andSince we have C(n + 1, k) = C(n, k – 1) + C(n, k) and
C(0, 0) = 1, we can use Pascal’s triangle to simplifyC(0, 0) = 1, we can use Pascal’s triangle to simplify
the computation of C(n, k):the computation of C(n, k):
C(0, 0) =C(0, 0) = 11
C(1, 0) =C(1, 0) = 11 C(1, 1) =C(1, 1) = 11
C(2, 0) =C(2, 0) = 11 C(2, 1) =C(2, 1) = 22 C(2, 2) =C(2, 2) = 11
C(3, 0) =C(3, 0) = 11 C(3, 1) =C(3, 1) = 33 C(3, 2) =C(3, 2) = 33 C(3, 3) =C(3, 3) = 11
C(4, 0) =C(4, 0) = 11 C(4, 1) =C(4, 1) = 44 C(4, 2) =C(4, 2) = 66 C(4, 3) =C(4, 3) = 44 C(4, 4) =C(4, 4) = 11
kk
nn
Fall 2002 CMSC 203 - Discrete 32
Binomial CoefficientsBinomial Coefficients
Expressions of the form C(n, k) are also calledExpressions of the form C(n, k) are also called
binomial coefficientsbinomial coefficients..
How come?How come?
AA binomial expressionbinomial expression is the sum of two terms,is the sum of two terms,
such as (a + b).such as (a + b).
Now consider (a + b)Now consider (a + b)22
= (a + b)(a + b).= (a + b)(a + b).
When expanding such expressions, we have toWhen expanding such expressions, we have to
form all possible products of a term in the firstform all possible products of a term in the first
factor and a term in the second factor:factor and a term in the second factor:
(a + b)(a + b)22
= a·a + a·b + b·a + b·b= a·a + a·b + b·a + b·b
Then we can sum identical terms:Then we can sum identical terms:
(a + b)(a + b)22
= a= a22
+ 2ab + b+ 2ab + b22
Fall 2002 CMSC 203 - Discrete 33
Binomial CoefficientsBinomial Coefficients
For (a + b)For (a + b)33
= (a + b)(a + b)(a + b) we have= (a + b)(a + b)(a + b) we have
(a + b)(a + b)33
== aaa + aab + aba + abb + baa + bab + bba + bbbaaa + aab + aba + abb + baa + bab + bba + bbb
(a + b)(a + b)33
= a= a33
+ 3a+ 3a22
b + 3abb + 3ab22
+ b+ b33
There is only one term a3
, because there is only one
possibility to form it: Choose a from all three
factors: C(3, 3) = 1.
There is three times the term a2
b, because there
are three possibilities to choose a from two out of
the three factors: C(3, 2) = 3.
Similarly, there is three times the term ab2
(C(3, 1) = 3) and once the term b3
(C(3, 0) = 1).
Fall 2002 CMSC 203 - Discrete 34
Binomial CoefficientsBinomial Coefficients
This leads us to the following formula:This leads us to the following formula:
j
n
j
jnn
bajnCba ∑=
−
⋅=+
0
),()(
With the help of Pascal’s triangle, this formula canWith the help of Pascal’s triangle, this formula can
considerably simplify the process of expanding powers ofconsiderably simplify the process of expanding powers of
binomial expressions.binomial expressions.
For example, the fifth row of Pascal’s triangleFor example, the fifth row of Pascal’s triangle
(1 – 4 – 6 – 4 – 1) helps us to compute (a + b)(1 – 4 – 6 – 4 – 1) helps us to compute (a + b)44
::
(a + b)(a + b)44
= a= a44
+ 4a+ 4a33
b + 6ab + 6a22
bb22
+ 4ab+ 4ab33
+ b+ b44
(Binomial Theorem)(Binomial Theorem)

More Related Content

What's hot

Lesson 22: Quadratic Forms
Lesson 22: Quadratic FormsLesson 22: Quadratic Forms
Lesson 22: Quadratic FormsMatthew Leingang
 
CMSC 56 | Lecture 12: Recursive Definition & Algorithms, and Program Correctness
CMSC 56 | Lecture 12: Recursive Definition & Algorithms, and Program CorrectnessCMSC 56 | Lecture 12: Recursive Definition & Algorithms, and Program Correctness
CMSC 56 | Lecture 12: Recursive Definition & Algorithms, and Program Correctnessallyn joy calcaben
 
CMSC 56 | Lecture 14: Representing Relations
CMSC 56 | Lecture 14: Representing RelationsCMSC 56 | Lecture 14: Representing Relations
CMSC 56 | Lecture 14: Representing Relationsallyn joy calcaben
 
Linear algebra-Basis & Dimension
Linear algebra-Basis & DimensionLinear algebra-Basis & Dimension
Linear algebra-Basis & DimensionManikanta satyala
 
Inverse Matrix & Determinants
Inverse Matrix & DeterminantsInverse Matrix & Determinants
Inverse Matrix & Determinantsitutor
 
CMSC 56 | Lecture 6: Sets & Set Operations
CMSC 56 | Lecture 6: Sets & Set OperationsCMSC 56 | Lecture 6: Sets & Set Operations
CMSC 56 | Lecture 6: Sets & Set Operationsallyn joy calcaben
 
2.1 Union, intersection and complement
2.1 Union, intersection and complement2.1 Union, intersection and complement
2.1 Union, intersection and complementJan Plaza
 
21 monotone sequences x
21 monotone sequences x21 monotone sequences x
21 monotone sequences xmath266
 
systems of linear equations & matrices
systems of linear equations & matricessystems of linear equations & matrices
systems of linear equations & matricesStudent
 
Fundamental principle of counting- ch 6 - Discrete Mathematics
Fundamental principle of counting- ch 6 - Discrete MathematicsFundamental principle of counting- ch 6 - Discrete Mathematics
Fundamental principle of counting- ch 6 - Discrete MathematicsOmnia A. Abdullah
 

What's hot (20)

Lesson 22: Quadratic Forms
Lesson 22: Quadratic FormsLesson 22: Quadratic Forms
Lesson 22: Quadratic Forms
 
CMSC 56 | Lecture 12: Recursive Definition & Algorithms, and Program Correctness
CMSC 56 | Lecture 12: Recursive Definition & Algorithms, and Program CorrectnessCMSC 56 | Lecture 12: Recursive Definition & Algorithms, and Program Correctness
CMSC 56 | Lecture 12: Recursive Definition & Algorithms, and Program Correctness
 
CMSC 56 | Lecture 14: Representing Relations
CMSC 56 | Lecture 14: Representing RelationsCMSC 56 | Lecture 14: Representing Relations
CMSC 56 | Lecture 14: Representing Relations
 
Graph Theory
Graph TheoryGraph Theory
Graph Theory
 
Linear algebra-Basis & Dimension
Linear algebra-Basis & DimensionLinear algebra-Basis & Dimension
Linear algebra-Basis & Dimension
 
Graph theory presentation
Graph theory presentationGraph theory presentation
Graph theory presentation
 
2.2 Set Operations
2.2 Set Operations2.2 Set Operations
2.2 Set Operations
 
Graph theory
Graph  theoryGraph  theory
Graph theory
 
Inverse Matrix & Determinants
Inverse Matrix & DeterminantsInverse Matrix & Determinants
Inverse Matrix & Determinants
 
Combinatorics
CombinatoricsCombinatorics
Combinatorics
 
Properties of straight lines
Properties of straight linesProperties of straight lines
Properties of straight lines
 
CMSC 56 | Lecture 6: Sets & Set Operations
CMSC 56 | Lecture 6: Sets & Set OperationsCMSC 56 | Lecture 6: Sets & Set Operations
CMSC 56 | Lecture 6: Sets & Set Operations
 
Discrete mathematics
Discrete mathematicsDiscrete mathematics
Discrete mathematics
 
2.1 Union, intersection and complement
2.1 Union, intersection and complement2.1 Union, intersection and complement
2.1 Union, intersection and complement
 
ABSTRACT ALGEBRA
ABSTRACT ALGEBRAABSTRACT ALGEBRA
ABSTRACT ALGEBRA
 
21 monotone sequences x
21 monotone sequences x21 monotone sequences x
21 monotone sequences x
 
Graph
GraphGraph
Graph
 
systems of linear equations & matrices
systems of linear equations & matricessystems of linear equations & matrices
systems of linear equations & matrices
 
Relations in Discrete Math
Relations in Discrete MathRelations in Discrete Math
Relations in Discrete Math
 
Fundamental principle of counting- ch 6 - Discrete Mathematics
Fundamental principle of counting- ch 6 - Discrete MathematicsFundamental principle of counting- ch 6 - Discrete Mathematics
Fundamental principle of counting- ch 6 - Discrete Mathematics
 

Similar to Discrete mathematics counting and logic relation

discrete mathematics counting for bachelor in information technology and comp...
discrete mathematics counting for bachelor in information technology and comp...discrete mathematics counting for bachelor in information technology and comp...
discrete mathematics counting for bachelor in information technology and comp...MUSASIZIRONALD
 
constructing_generic_algorithms__ben_deane__cppcon_2020.pdf
constructing_generic_algorithms__ben_deane__cppcon_2020.pdfconstructing_generic_algorithms__ben_deane__cppcon_2020.pdf
constructing_generic_algorithms__ben_deane__cppcon_2020.pdfSayanSamanta39
 
Greedy algorithms -Making change-Knapsack-Prim's-Kruskal's
Greedy algorithms -Making change-Knapsack-Prim's-Kruskal'sGreedy algorithms -Making change-Knapsack-Prim's-Kruskal's
Greedy algorithms -Making change-Knapsack-Prim's-Kruskal'sJay Patel
 
Ds presentation1
Ds presentation1Ds presentation1
Ds presentation1Irfan Khan
 
2021 1학기 정기 세미나 2주차
2021 1학기 정기 세미나 2주차2021 1학기 정기 세미나 2주차
2021 1학기 정기 세미나 2주차Moonki Choi
 
FACTORING CRYPTOSYSTEM MODULI WHEN THE CO-FACTORS DIFFERENCE IS BOUNDED
FACTORING CRYPTOSYSTEM MODULI WHEN THE CO-FACTORS DIFFERENCE IS BOUNDEDFACTORING CRYPTOSYSTEM MODULI WHEN THE CO-FACTORS DIFFERENCE IS BOUNDED
FACTORING CRYPTOSYSTEM MODULI WHEN THE CO-FACTORS DIFFERENCE IS BOUNDEDZac Darcy
 
Assgnment=hungarian method
Assgnment=hungarian methodAssgnment=hungarian method
Assgnment=hungarian methodJoseph Konnully
 
Merge sort analysis and its real time applications
Merge sort analysis and its real time applicationsMerge sort analysis and its real time applications
Merge sort analysis and its real time applicationsyazad dumasia
 
tutorial5.ppt
tutorial5.ppttutorial5.ppt
tutorial5.pptjvjfvvoa
 
Sienna 1 intro
Sienna 1 introSienna 1 intro
Sienna 1 introchidabdu
 
Computer notes - Sorting
Computer notes  - SortingComputer notes  - Sorting
Computer notes - Sortingecomputernotes
 
Bt0080 fundamentals of algorithms1
Bt0080 fundamentals of algorithms1Bt0080 fundamentals of algorithms1
Bt0080 fundamentals of algorithms1Techglyphs
 

Similar to Discrete mathematics counting and logic relation (20)

discrete mathematics counting for bachelor in information technology and comp...
discrete mathematics counting for bachelor in information technology and comp...discrete mathematics counting for bachelor in information technology and comp...
discrete mathematics counting for bachelor in information technology and comp...
 
Counting DM
Counting DMCounting DM
Counting DM
 
Bitwise
BitwiseBitwise
Bitwise
 
QMC: Transition Workshop - Probability Models for Discretization Uncertainty ...
QMC: Transition Workshop - Probability Models for Discretization Uncertainty ...QMC: Transition Workshop - Probability Models for Discretization Uncertainty ...
QMC: Transition Workshop - Probability Models for Discretization Uncertainty ...
 
constructing_generic_algorithms__ben_deane__cppcon_2020.pdf
constructing_generic_algorithms__ben_deane__cppcon_2020.pdfconstructing_generic_algorithms__ben_deane__cppcon_2020.pdf
constructing_generic_algorithms__ben_deane__cppcon_2020.pdf
 
Randomized algorithms ver 1.0
Randomized algorithms ver 1.0Randomized algorithms ver 1.0
Randomized algorithms ver 1.0
 
Greedy algorithms -Making change-Knapsack-Prim's-Kruskal's
Greedy algorithms -Making change-Knapsack-Prim's-Kruskal'sGreedy algorithms -Making change-Knapsack-Prim's-Kruskal's
Greedy algorithms -Making change-Knapsack-Prim's-Kruskal's
 
Ds presentation1
Ds presentation1Ds presentation1
Ds presentation1
 
2021 1학기 정기 세미나 2주차
2021 1학기 정기 세미나 2주차2021 1학기 정기 세미나 2주차
2021 1학기 정기 세미나 2주차
 
FACTORING CRYPTOSYSTEM MODULI WHEN THE CO-FACTORS DIFFERENCE IS BOUNDED
FACTORING CRYPTOSYSTEM MODULI WHEN THE CO-FACTORS DIFFERENCE IS BOUNDEDFACTORING CRYPTOSYSTEM MODULI WHEN THE CO-FACTORS DIFFERENCE IS BOUNDED
FACTORING CRYPTOSYSTEM MODULI WHEN THE CO-FACTORS DIFFERENCE IS BOUNDED
 
Assgnment=hungarian method
Assgnment=hungarian methodAssgnment=hungarian method
Assgnment=hungarian method
 
Hamlet_Khachatryan_57--61
Hamlet_Khachatryan_57--61Hamlet_Khachatryan_57--61
Hamlet_Khachatryan_57--61
 
Merge sort analysis and its real time applications
Merge sort analysis and its real time applicationsMerge sort analysis and its real time applications
Merge sort analysis and its real time applications
 
tutorial5.ppt
tutorial5.ppttutorial5.ppt
tutorial5.ppt
 
Algorithms
AlgorithmsAlgorithms
Algorithms
 
Cis435 week06
Cis435 week06Cis435 week06
Cis435 week06
 
Sienna 1 intro
Sienna 1 introSienna 1 intro
Sienna 1 intro
 
Shors'algorithm simplified.pptx
Shors'algorithm simplified.pptxShors'algorithm simplified.pptx
Shors'algorithm simplified.pptx
 
Computer notes - Sorting
Computer notes  - SortingComputer notes  - Sorting
Computer notes - Sorting
 
Bt0080 fundamentals of algorithms1
Bt0080 fundamentals of algorithms1Bt0080 fundamentals of algorithms1
Bt0080 fundamentals of algorithms1
 

More from Self-Employed

Queue AS an ADT (Abstract Data Type)
Queue AS an ADT (Abstract Data Type)Queue AS an ADT (Abstract Data Type)
Queue AS an ADT (Abstract Data Type)Self-Employed
 
Infix prefix postfix
Infix prefix postfixInfix prefix postfix
Infix prefix postfixSelf-Employed
 
Algorithm and C code related to data structure
Algorithm and C code related to data structureAlgorithm and C code related to data structure
Algorithm and C code related to data structureSelf-Employed
 
Abstract data types (adt) intro to data structure part 2
Abstract data types (adt)   intro to data structure part 2Abstract data types (adt)   intro to data structure part 2
Abstract data types (adt) intro to data structure part 2Self-Employed
 
2.2 inverse of a matrix
2.2 inverse of a matrix2.2 inverse of a matrix
2.2 inverse of a matrixSelf-Employed
 

More from Self-Employed (7)

Queue AS an ADT (Abstract Data Type)
Queue AS an ADT (Abstract Data Type)Queue AS an ADT (Abstract Data Type)
Queue AS an ADT (Abstract Data Type)
 
Infix prefix postfix
Infix prefix postfixInfix prefix postfix
Infix prefix postfix
 
Ds lec 5_chap4
Ds lec 5_chap4Ds lec 5_chap4
Ds lec 5_chap4
 
Algorithm and C code related to data structure
Algorithm and C code related to data structureAlgorithm and C code related to data structure
Algorithm and C code related to data structure
 
Abstract data types (adt) intro to data structure part 2
Abstract data types (adt)   intro to data structure part 2Abstract data types (adt)   intro to data structure part 2
Abstract data types (adt) intro to data structure part 2
 
2.2 inverse of a matrix
2.2 inverse of a matrix2.2 inverse of a matrix
2.2 inverse of a matrix
 
8086 architecture
8086 architecture8086 architecture
8086 architecture
 

Recently uploaded

Biting mechanism of poisonous snakes.pdf
Biting mechanism of poisonous snakes.pdfBiting mechanism of poisonous snakes.pdf
Biting mechanism of poisonous snakes.pdfadityarao40181
 
Final demo Grade 9 for demo Plan dessert.pptx
Final demo Grade 9 for demo Plan dessert.pptxFinal demo Grade 9 for demo Plan dessert.pptx
Final demo Grade 9 for demo Plan dessert.pptxAvyJaneVismanos
 
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
 
Presiding Officer Training module 2024 lok sabha elections
Presiding Officer Training module 2024 lok sabha electionsPresiding Officer Training module 2024 lok sabha elections
Presiding Officer Training module 2024 lok sabha electionsanshu789521
 
Sanyam Choudhary Chemistry practical.pdf
Sanyam Choudhary Chemistry practical.pdfSanyam Choudhary Chemistry practical.pdf
Sanyam Choudhary Chemistry practical.pdfsanyamsingh5019
 
internship ppt on smartinternz platform as salesforce developer
internship ppt on smartinternz platform as salesforce developerinternship ppt on smartinternz platform as salesforce developer
internship ppt on smartinternz platform as salesforce developerunnathinaik
 
Science 7 - LAND and SEA BREEZE and its Characteristics
Science 7 - LAND and SEA BREEZE and its CharacteristicsScience 7 - LAND and SEA BREEZE and its Characteristics
Science 7 - LAND and SEA BREEZE and its CharacteristicsKarinaGenton
 
Kisan Call Centre - To harness potential of ICT in Agriculture by answer farm...
Kisan Call Centre - To harness potential of ICT in Agriculture by answer farm...Kisan Call Centre - To harness potential of ICT in Agriculture by answer farm...
Kisan Call Centre - To harness potential of ICT in Agriculture by answer farm...Krashi Coaching
 
Pharmacognosy Flower 3. Compositae 2023.pdf
Pharmacognosy Flower 3. Compositae 2023.pdfPharmacognosy Flower 3. Compositae 2023.pdf
Pharmacognosy Flower 3. Compositae 2023.pdfMahmoud M. Sallam
 
The Most Excellent Way | 1 Corinthians 13
The Most Excellent Way | 1 Corinthians 13The Most Excellent Way | 1 Corinthians 13
The Most Excellent Way | 1 Corinthians 13Steve Thomason
 
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
 
BASLIQ CURRENT LOOKBOOK LOOKBOOK(1) (1).pdf
BASLIQ CURRENT LOOKBOOK  LOOKBOOK(1) (1).pdfBASLIQ CURRENT LOOKBOOK  LOOKBOOK(1) (1).pdf
BASLIQ CURRENT LOOKBOOK LOOKBOOK(1) (1).pdfSoniaTolstoy
 
ENGLISH5 QUARTER4 MODULE1 WEEK1-3 How Visual and Multimedia Elements.pptx
ENGLISH5 QUARTER4 MODULE1 WEEK1-3 How Visual and Multimedia Elements.pptxENGLISH5 QUARTER4 MODULE1 WEEK1-3 How Visual and Multimedia Elements.pptx
ENGLISH5 QUARTER4 MODULE1 WEEK1-3 How Visual and Multimedia Elements.pptxAnaBeatriceAblay2
 
How to Configure Email Server in Odoo 17
How to Configure Email Server in Odoo 17How to Configure Email Server in Odoo 17
How to Configure Email Server in Odoo 17Celine George
 
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
 
Paris 2024 Olympic Geographies - an activity
Paris 2024 Olympic Geographies - an activityParis 2024 Olympic Geographies - an activity
Paris 2024 Olympic Geographies - an activityGeoBlogs
 
Software Engineering Methodologies (overview)
Software Engineering Methodologies (overview)Software Engineering Methodologies (overview)
Software Engineering Methodologies (overview)eniolaolutunde
 
Organic Name Reactions for the students and aspirants of Chemistry12th.pptx
Organic Name Reactions  for the students and aspirants of Chemistry12th.pptxOrganic Name Reactions  for the students and aspirants of Chemistry12th.pptx
Organic Name Reactions for the students and aspirants of Chemistry12th.pptxVS Mahajan Coaching Centre
 
“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
 
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
 

Recently uploaded (20)

Biting mechanism of poisonous snakes.pdf
Biting mechanism of poisonous snakes.pdfBiting mechanism of poisonous snakes.pdf
Biting mechanism of poisonous snakes.pdf
 
Final demo Grade 9 for demo Plan dessert.pptx
Final demo Grade 9 for demo Plan dessert.pptxFinal demo Grade 9 for demo Plan dessert.pptx
Final demo Grade 9 for demo Plan dessert.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
 
Presiding Officer Training module 2024 lok sabha elections
Presiding Officer Training module 2024 lok sabha electionsPresiding Officer Training module 2024 lok sabha elections
Presiding Officer Training module 2024 lok sabha elections
 
Sanyam Choudhary Chemistry practical.pdf
Sanyam Choudhary Chemistry practical.pdfSanyam Choudhary Chemistry practical.pdf
Sanyam Choudhary Chemistry practical.pdf
 
internship ppt on smartinternz platform as salesforce developer
internship ppt on smartinternz platform as salesforce developerinternship ppt on smartinternz platform as salesforce developer
internship ppt on smartinternz platform as salesforce developer
 
Science 7 - LAND and SEA BREEZE and its Characteristics
Science 7 - LAND and SEA BREEZE and its CharacteristicsScience 7 - LAND and SEA BREEZE and its Characteristics
Science 7 - LAND and SEA BREEZE and its Characteristics
 
Kisan Call Centre - To harness potential of ICT in Agriculture by answer farm...
Kisan Call Centre - To harness potential of ICT in Agriculture by answer farm...Kisan Call Centre - To harness potential of ICT in Agriculture by answer farm...
Kisan Call Centre - To harness potential of ICT in Agriculture by answer farm...
 
Pharmacognosy Flower 3. Compositae 2023.pdf
Pharmacognosy Flower 3. Compositae 2023.pdfPharmacognosy Flower 3. Compositae 2023.pdf
Pharmacognosy Flower 3. Compositae 2023.pdf
 
The Most Excellent Way | 1 Corinthians 13
The Most Excellent Way | 1 Corinthians 13The Most Excellent Way | 1 Corinthians 13
The Most Excellent Way | 1 Corinthians 13
 
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
 
BASLIQ CURRENT LOOKBOOK LOOKBOOK(1) (1).pdf
BASLIQ CURRENT LOOKBOOK  LOOKBOOK(1) (1).pdfBASLIQ CURRENT LOOKBOOK  LOOKBOOK(1) (1).pdf
BASLIQ CURRENT LOOKBOOK LOOKBOOK(1) (1).pdf
 
ENGLISH5 QUARTER4 MODULE1 WEEK1-3 How Visual and Multimedia Elements.pptx
ENGLISH5 QUARTER4 MODULE1 WEEK1-3 How Visual and Multimedia Elements.pptxENGLISH5 QUARTER4 MODULE1 WEEK1-3 How Visual and Multimedia Elements.pptx
ENGLISH5 QUARTER4 MODULE1 WEEK1-3 How Visual and Multimedia Elements.pptx
 
How to Configure Email Server in Odoo 17
How to Configure Email Server in Odoo 17How to Configure Email Server in Odoo 17
How to Configure Email Server in Odoo 17
 
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
 
Paris 2024 Olympic Geographies - an activity
Paris 2024 Olympic Geographies - an activityParis 2024 Olympic Geographies - an activity
Paris 2024 Olympic Geographies - an activity
 
Software Engineering Methodologies (overview)
Software Engineering Methodologies (overview)Software Engineering Methodologies (overview)
Software Engineering Methodologies (overview)
 
Organic Name Reactions for the students and aspirants of Chemistry12th.pptx
Organic Name Reactions  for the students and aspirants of Chemistry12th.pptxOrganic Name Reactions  for the students and aspirants of Chemistry12th.pptx
Organic Name Reactions for the students and aspirants of Chemistry12th.pptx
 
“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...
 
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
 

Discrete mathematics counting and logic relation

  • 1. Fall 2002 CMSC 203 - Discrete 1 One, two, three, we’re…One, two, three, we’re… CountingCounting
  • 2. Fall 2002 CMSC 203 - Discrete 2 Basic Counting PrinciplesBasic Counting Principles Counting problemsCounting problems are of the following kind:are of the following kind: ““How manyHow many different 8-letter passwords aredifferent 8-letter passwords are there?”there?” ““How manyHow many possible ways are there to pick 11possible ways are there to pick 11 soccer players out of a 20-player team?”soccer players out of a 20-player team?” Most importantly, counting is the basis forMost importantly, counting is the basis for computingcomputing probabilities of discrete eventsprobabilities of discrete events.. (“What is the probability of winning the lottery?”)(“What is the probability of winning the lottery?”)
  • 3. Fall 2002 CMSC 203 - Discrete 3 Basic Counting PrinciplesBasic Counting Principles The sum rule:The sum rule: If a task can be done in nIf a task can be done in n11 ways and a second taskways and a second task in nin n22 ways, and if these two tasks cannot be doneways, and if these two tasks cannot be done at the same time, then there are nat the same time, then there are n11 + n+ n22 ways to doways to do either task.either task. Example:Example: The department will award a free computer toThe department will award a free computer to either a CS student or a CS professor.either a CS student or a CS professor. How many different choices are there, if thereHow many different choices are there, if there are 530 students and 15 professors?are 530 students and 15 professors? There are 530 + 15 = 545 choices.There are 530 + 15 = 545 choices.
  • 4. Fall 2002 CMSC 203 - Discrete 4 Basic Counting PrinciplesBasic Counting Principles Generalized sum rule:Generalized sum rule: If we have tasks TIf we have tasks T11, T, T22, …, T, …, Tmm that can be done inthat can be done in nn11, n, n22, …, n, …, nmm ways, respectively, and no two of theseways, respectively, and no two of these tasks can be done at the same time, then theretasks can be done at the same time, then there are nare n11 + n+ n22 + … + n+ … + nmm ways to do one of these tasks.ways to do one of these tasks.
  • 5. Fall 2002 CMSC 203 - Discrete 5 Basic Counting PrinciplesBasic Counting Principles The product rule:The product rule: Suppose that a procedure can be broken downSuppose that a procedure can be broken down into two successive tasks. If there are ninto two successive tasks. If there are n11 ways toways to do the first task and ndo the first task and n22 ways to do the secondways to do the second task after the first task has been done, thentask after the first task has been done, then there are nthere are n11nn22 ways to do the procedure.ways to do the procedure.
  • 6. Fall 2002 CMSC 203 - Discrete 6 Basic Counting PrinciplesBasic Counting Principles Example:Example: How many different license plates are there thatHow many different license plates are there that containing exactly three English letters ?containing exactly three English letters ? Solution:Solution: There are 26 possibilities to pick the first letter,There are 26 possibilities to pick the first letter, then 26 possibilities for the second one, and 26then 26 possibilities for the second one, and 26 for the last one.for the last one. So there are 26So there are 26⋅⋅2626⋅⋅26 = 17576 different license26 = 17576 different license plates.plates.
  • 7. Fall 2002 CMSC 203 - Discrete 7 Basic Counting PrinciplesBasic Counting Principles Generalized product rule:Generalized product rule: If we have a procedure consisting of sequentialIf we have a procedure consisting of sequential tasks Ttasks T11, T, T22, …, T, …, Tmm that can be done in nthat can be done in n11, n, n22, …, n, …, nmm ways, respectively, then there are nways, respectively, then there are n11 ⋅⋅ nn22 ⋅⋅ …… ⋅⋅ nnmm ways to carry out the procedure.ways to carry out the procedure.
  • 8. Fall 2002 CMSC 203 - Discrete 8 Basic Counting PrinciplesBasic Counting Principles The sum and product rules can also be phrased inThe sum and product rules can also be phrased in terms ofterms of set theoryset theory.. Sum rule:Sum rule: Let ALet A11, A, A22, …, A, …, Amm be disjoint sets. Thenbe disjoint sets. Then the number of ways to choose any element fromthe number of ways to choose any element from one of these sets is |Aone of these sets is |A11 ∪∪ AA22 ∪∪ …… ∪∪ AAmm | =| = |A|A11| + |A| + |A22| + … + |A| + … + |Amm|.|. Product rule:Product rule: Let ALet A11, A, A22, …, A, …, Amm be finite sets. Thenbe finite sets. Then the number of ways to choose one element fromthe number of ways to choose one element from each set in the order Aeach set in the order A11, A, A22, …, A, …, Amm isis |A|A11 ×× AA22 ×× …… ×× AAmm | = |A| = |A11|| ⋅⋅ |A|A22|| ⋅⋅ …… ⋅⋅ |A|Amm|.|.
  • 9. Fall 2002 CMSC 203 - Discrete 9 Inclusion-ExclusionInclusion-Exclusion How many bit strings of length 8 either start with aHow many bit strings of length 8 either start with a 1 or end with 00?1 or end with 00? Task 1:Task 1: Construct a string of length 8 that startsConstruct a string of length 8 that starts with a 1.with a 1. There is one way to pick the first bit (1),There is one way to pick the first bit (1), two ways to pick the second bit (0 or 1),two ways to pick the second bit (0 or 1), two ways to pick the third bit (0 or 1),two ways to pick the third bit (0 or 1), .. .. .. two ways to pick the eighth bit (0 or 1).two ways to pick the eighth bit (0 or 1). Product rule:Product rule: Task 1 can be done in 1Task 1 can be done in 1⋅⋅2277 = 128 ways.= 128 ways.
  • 10. Fall 2002 CMSC 203 - Discrete 10 Inclusion-ExclusionInclusion-Exclusion Task 2:Task 2: Construct a string of length 8 that endsConstruct a string of length 8 that ends with 00.with 00. There are two ways to pick the first bit (0 or 1),There are two ways to pick the first bit (0 or 1), two ways to pick the second bit (0 or 1),two ways to pick the second bit (0 or 1), .. .. .. two ways to pick the sixth bit (0 or 1),two ways to pick the sixth bit (0 or 1), one way to pick the seventh bit (0), andone way to pick the seventh bit (0), and one way to pick the eighth bit (0).one way to pick the eighth bit (0). Product rule:Product rule: Task 2 can be done in 2Task 2 can be done in 266 = 64 ways.= 64 ways.
  • 11. Fall 2002 CMSC 203 - Discrete 11 Inclusion-ExclusionInclusion-Exclusion Since there are 128 ways to do Task 1 and 64 waysSince there are 128 ways to do Task 1 and 64 ways to do Task 2, does this mean that there are 192 bitto do Task 2, does this mean that there are 192 bit strings either starting with 1 or ending with 00 ?strings either starting with 1 or ending with 00 ? No, because here Task 1 and Task 2 can be doneNo, because here Task 1 and Task 2 can be done atat the same timethe same time.. When we carry out Task 1 and create stringsWhen we carry out Task 1 and create strings starting with 1, some of these strings end with 00.starting with 1, some of these strings end with 00. Therefore, we sometimes do Tasks 1 and 2 at theTherefore, we sometimes do Tasks 1 and 2 at the same time, sosame time, so the sum rule does not applythe sum rule does not apply..
  • 12. Fall 2002 CMSC 203 - Discrete 12 Inclusion-ExclusionInclusion-Exclusion If we want to use the sum rule in such a case, weIf we want to use the sum rule in such a case, we have to subtract the cases when Tasks 1 and 2 arehave to subtract the cases when Tasks 1 and 2 are done at the same time.done at the same time. How many cases are there, that is, how manyHow many cases are there, that is, how many strings start with 1strings start with 1 andand end with 00?end with 00? There is one way to pick the first bit (1),There is one way to pick the first bit (1), two ways for the second, …, sixth bit (0 or 1),two ways for the second, …, sixth bit (0 or 1), one way for the seventh, eighth bit (0).one way for the seventh, eighth bit (0). Product rule:Product rule: In 2In 255 = 32 cases, Tasks 1 and 2 are= 32 cases, Tasks 1 and 2 are carried out at the same time.carried out at the same time.
  • 13. Fall 2002 CMSC 203 - Discrete 13 Inclusion-ExclusionInclusion-Exclusion Since there are 128 ways to complete Task 1 andSince there are 128 ways to complete Task 1 and 64 ways to complete Task 2, and in 32 of these64 ways to complete Task 2, and in 32 of these cases Tasks 1 and 2 are completed at the samecases Tasks 1 and 2 are completed at the same time, there aretime, there are 128 + 64 – 32 = 160 ways to do either task.128 + 64 – 32 = 160 ways to do either task. In set theory, this corresponds to sets AIn set theory, this corresponds to sets A11 and Aand A22 that arethat are notnot disjoint. Then we have:disjoint. Then we have: |A|A11 ∪∪ AA22| = |A| = |A11| + |A| + |A22| - |A| - |A11 ∩∩ AA22|| This is called theThis is called the principle of inclusion-exclusion.principle of inclusion-exclusion.
  • 14. Fall 2002 CMSC 203 - Discrete 14 Tree DiagramsTree Diagrams How many bit strings of length four do not haveHow many bit strings of length four do not have two consecutive 1s?two consecutive 1s? Task 1Task 1 Task 2Task 2 Task 3Task 3 Task 4Task 4 (1(1stst bit)bit) (2(2ndnd bit)bit) (3(3rdrd bit)bit) (4(4thth bit)bit) 00 00 00 00 11 11 00 11 00 00 11 11 00 00 00 11 11 00 There are 8 strings.There are 8 strings.
  • 15. Fall 2002 CMSC 203 - Discrete 15 The Pigeonhole PrincipleThe Pigeonhole Principle The pigeonhole principle:The pigeonhole principle: If (k + 1) or moreIf (k + 1) or more objects are placed into k boxes, then there isobjects are placed into k boxes, then there is atat leastleast one box containing two or more of theone box containing two or more of the objects.objects. Example 1:Example 1: If there are 11 players in a soccerIf there are 11 players in a soccer team that wins 12-0, there must be at least oneteam that wins 12-0, there must be at least one player in the team who scored at least twice.player in the team who scored at least twice. Example 2:Example 2: If you have 6 classes from Monday toIf you have 6 classes from Monday to Friday, there must be at least one day on which youFriday, there must be at least one day on which you have at least two classes.have at least two classes.
  • 16. Fall 2002 CMSC 203 - Discrete 16 The Pigeonhole PrincipleThe Pigeonhole Principle The generalized pigeonhole principle:The generalized pigeonhole principle: If NIf N objects are placed into k boxes, then there isobjects are placed into k boxes, then there is atat leastleast one box containing at leastone box containing at least N/kN/k of theof the objects.objects. Example 1:Example 1: In our 60-student class, at least 12In our 60-student class, at least 12 students will get the same letter grade (A, B, C, D,students will get the same letter grade (A, B, C, D, or F).or F).
  • 17. Fall 2002 CMSC 203 - Discrete 17 The Pigeonhole PrincipleThe Pigeonhole Principle Example 2:Example 2: Assume you have a drawer containing aAssume you have a drawer containing a random distribution of a dozen brown socks and arandom distribution of a dozen brown socks and a dozen black socks. It is dark, so how many socks dodozen black socks. It is dark, so how many socks do you have to pick to be sure that among them thereyou have to pick to be sure that among them there is a matching pair?is a matching pair? There are two types of socks, so if you pick atThere are two types of socks, so if you pick at least 3 socks, there must be either at least twoleast 3 socks, there must be either at least two brown socks or at least two black socks.brown socks or at least two black socks. Generalized pigeonhole principle:Generalized pigeonhole principle: 3/23/2 = 2.= 2.
  • 18. Fall 2002 CMSC 203 - Discrete 18 Permutations and CombinationsPermutations and Combinations How many ways are there to pick a set of 3 peopleHow many ways are there to pick a set of 3 people from a group of 6?from a group of 6? There are 6 choices for the first person, 5 for theThere are 6 choices for the first person, 5 for the second one, and 4 for the third one, so there aresecond one, and 4 for the third one, so there are 66⋅⋅55⋅⋅4 = 120 ways to do this.4 = 120 ways to do this. This is not the correct result!This is not the correct result! For example, picking person C, then person A, andFor example, picking person C, then person A, and then person E leads to thethen person E leads to the same groupsame group as firstas first picking E, then C, and then A.picking E, then C, and then A. However, these cases are countedHowever, these cases are counted separatelyseparately inin the above equation.the above equation.
  • 19. Fall 2002 CMSC 203 - Discrete 19 Permutations and CombinationsPermutations and Combinations So how can we compute how many differentSo how can we compute how many different subsets of people can be picked (that is, we want tosubsets of people can be picked (that is, we want to disregard the order of picking) ?disregard the order of picking) ? To find out about this, we need to look atTo find out about this, we need to look at permutations.permutations. AA permutationpermutation of a set of distinct objects is anof a set of distinct objects is an ordered arrangement of these objects.ordered arrangement of these objects. An ordered arrangement of r elements of a set isAn ordered arrangement of r elements of a set is called ancalled an r-permutationr-permutation..
  • 20. Fall 2002 CMSC 203 - Discrete 20 Permutations and CombinationsPermutations and Combinations Example:Example: Let S = {1, 2, 3}.Let S = {1, 2, 3}. The arrangement 3, 1, 2 is a permutation of S.The arrangement 3, 1, 2 is a permutation of S. The arrangement 3, 2 is a 2-permutation of S.The arrangement 3, 2 is a 2-permutation of S. The number of r-permutations of a set with nThe number of r-permutations of a set with n distinct elements is denoted bydistinct elements is denoted by P(n, r).P(n, r). We can calculate P(n, r) with the product rule:We can calculate P(n, r) with the product rule: P(n, r) = nP(n, r) = n⋅⋅(n – 1)(n – 1)⋅⋅(n – 2)(n – 2) ⋅⋅……⋅⋅(n – r + 1).(n – r + 1). (n choices for the first element, (n – 1) for the(n choices for the first element, (n – 1) for the second one, (n – 2) for the third one…)second one, (n – 2) for the third one…)
  • 21. Fall 2002 CMSC 203 - Discrete 21 Permutations and CombinationsPermutations and Combinations Example:Example: P(8, 3) = 8P(8, 3) = 8⋅⋅77⋅⋅6 = 3366 = 336 = (8= (8⋅⋅77⋅⋅66⋅⋅55⋅⋅44⋅⋅33⋅⋅22⋅⋅1)/(51)/(5⋅⋅44⋅⋅33⋅⋅22⋅⋅1)1) General formula:General formula: P(n, r) = n!/(n – r)!P(n, r) = n!/(n – r)! Knowing this, we can return to our initial question:Knowing this, we can return to our initial question: How many ways are there to pick a set of 3 peopleHow many ways are there to pick a set of 3 people from a group of 6 (disregarding the order offrom a group of 6 (disregarding the order of picking)?picking)?
  • 22. Fall 2002 CMSC 203 - Discrete 22 Permutations and CombinationsPermutations and Combinations AnAn r-combinationr-combination of elements of a set is anof elements of a set is an unordered selection of r elements from the set.unordered selection of r elements from the set. Thus, an r-combination is simply a subset of the setThus, an r-combination is simply a subset of the set with r elements.with r elements. Example:Example: Let S = {1, 2, 3, 4}.Let S = {1, 2, 3, 4}. Then {1, 3, 4} is a 3-combination from S.Then {1, 3, 4} is a 3-combination from S. The number of r-combinations of a set with nThe number of r-combinations of a set with n distinct elements is denoted by C(n, r).distinct elements is denoted by C(n, r). Example:Example: C(4, 2) = 6, since, for example, the 2-C(4, 2) = 6, since, for example, the 2- combinations of a set {1, 2, 3, 4} are {1, 2}, {1, 3}, {1,combinations of a set {1, 2, 3, 4} are {1, 2}, {1, 3}, {1, 4}, {2, 3}, {2, 4}, {3, 4}.4}, {2, 3}, {2, 4}, {3, 4}.
  • 23. Fall 2002 CMSC 203 - Discrete 23 Permutations and CombinationsPermutations and Combinations How can we calculate C(n, r)?How can we calculate C(n, r)? Consider that we can obtain the r-permutation of aConsider that we can obtain the r-permutation of a set in the following way:set in the following way: First,First, we form all the r-combinations of the setwe form all the r-combinations of the set (there are C(n, r) such r-combinations).(there are C(n, r) such r-combinations). Then,Then, we generate all possible orderings in each ofwe generate all possible orderings in each of these r-combinations (there are P(r, r) suchthese r-combinations (there are P(r, r) such orderings in each case).orderings in each case). Therefore, we have:Therefore, we have: P(n, r) = C(n, r)P(n, r) = C(n, r)⋅⋅P(r, r)P(r, r)
  • 24. Fall 2002 CMSC 203 - Discrete 24 Permutations and CombinationsPermutations and Combinations C(n, r) = P(n, r)/P(r, r)C(n, r) = P(n, r)/P(r, r) = n!/(n – r)!/(r!/(r – r)!)= n!/(n – r)!/(r!/(r – r)!) = n!/(r!(n – r)!)= n!/(r!(n – r)!) Now we can answer our initial question:Now we can answer our initial question: How many ways are there to pick a set of 3 peopleHow many ways are there to pick a set of 3 people from a group of 6 (disregarding the order offrom a group of 6 (disregarding the order of picking)?picking)? C(6, 3) = 6!/(3!C(6, 3) = 6!/(3!⋅⋅3!) = 720/(63!) = 720/(6⋅⋅6) = 720/36 = 206) = 720/36 = 20 There are 20 different ways, that is, 20 differentThere are 20 different ways, that is, 20 different groups to be picked.groups to be picked.
  • 25. Fall 2002 CMSC 203 - Discrete 25 Permutations and CombinationsPermutations and Combinations Corollary:Corollary: Let n and r be nonnegative integers with rLet n and r be nonnegative integers with r ≤≤ n.n. Then C(n, r) = C(n, n – r).Then C(n, r) = C(n, n – r). Note thatNote that “picking a group of r people from a“picking a group of r people from a group of n people”group of n people” is the same asis the same as “splitting a group“splitting a group of n people into a group of r people and anotherof n people into a group of r people and another group of (n – r) people”.group of (n – r) people”. Please also look at proof on page 323.Please also look at proof on page 323.
  • 26. Fall 2002 CMSC 203 - Discrete 26 Permutations and CombinationsPermutations and Combinations Example: A soccer club has 8 female and 7 male members. For today’s match, the coach wants to have 6 female and 5 male players on the grass. How many possible configurations are there? C(8, 6) ⋅⋅ C(7, 5) = 8!/(6!C(7, 5) = 8!/(6!⋅⋅2!)2!) ⋅⋅ 7!/(5!7!/(5!⋅⋅2!)2!) = 28= 28⋅⋅2121 = 588= 588
  • 27. Fall 2002 CMSC 203 - Discrete 27 CombinationsCombinations We also saw the following:We also saw the following: ),( !)!( ! )]!([)!( ! ),( rnC rrn n rnnrn n rnnC = − = −−− =− This symmetry is intuitively plausible. For example,This symmetry is intuitively plausible. For example, let us consider a set containing six elements (n = 6).let us consider a set containing six elements (n = 6). Picking twoPicking two elements andelements and leaving fourleaving four is essentiallyis essentially the same asthe same as picking fourpicking four elements andelements and leaving twoleaving two.. In either case, our number of choices is theIn either case, our number of choices is the number of possibilities tonumber of possibilities to dividedivide the set into onethe set into one set containing two elements and another setset containing two elements and another set containing four elements.containing four elements.
  • 28. Fall 2002 CMSC 203 - Discrete 28 CombinationsCombinations Pascal’s Identity:Pascal’s Identity: Let n and k be positive integers with nLet n and k be positive integers with n ≥≥ k.k. Then C(n + 1, k) = C(n, k – 1) + C(n, k).Then C(n + 1, k) = C(n, k – 1) + C(n, k). How can this be explained?How can this be explained? What is it good for?What is it good for?
  • 29. Fall 2002 CMSC 203 - Discrete 29 CombinationsCombinations Imagine a set S containing n elements and a set TImagine a set S containing n elements and a set T containing (n + 1) elements, namely all elements incontaining (n + 1) elements, namely all elements in S plus a new elementS plus a new element aa.. Calculating C(n + 1, k) is equivalent to answeringCalculating C(n + 1, k) is equivalent to answering the question: How many subsets of T containing kthe question: How many subsets of T containing k items are there?items are there? Case I:Case I: The subset contains (k – 1) elements of SThe subset contains (k – 1) elements of S plus the elementplus the element aa: C(n, k – 1) choices.: C(n, k – 1) choices. Case II:Case II: The subset contains k elements of S andThe subset contains k elements of S and does not containdoes not contain aa: C(n, k) choices.: C(n, k) choices. Sum Rule:Sum Rule: C(n + 1, k) = C(n, k – 1) + C(n, k).C(n + 1, k) = C(n, k – 1) + C(n, k).
  • 30. Fall 2002 CMSC 203 - Discrete 30 Pascal’s TrianglePascal’s Triangle In Pascal’s triangle, each number is the sum ofIn Pascal’s triangle, each number is the sum of the numbers to its upper left and upper right:the numbers to its upper left and upper right: 11 11 11 11 22 11 11 33 33 11 11 44 66 44 11 …… …… …… …… …… ……
  • 31. Fall 2002 CMSC 203 - Discrete 31 Pascal’s TrianglePascal’s Triangle Since we have C(n + 1, k) = C(n, k – 1) + C(n, k) andSince we have C(n + 1, k) = C(n, k – 1) + C(n, k) and C(0, 0) = 1, we can use Pascal’s triangle to simplifyC(0, 0) = 1, we can use Pascal’s triangle to simplify the computation of C(n, k):the computation of C(n, k): C(0, 0) =C(0, 0) = 11 C(1, 0) =C(1, 0) = 11 C(1, 1) =C(1, 1) = 11 C(2, 0) =C(2, 0) = 11 C(2, 1) =C(2, 1) = 22 C(2, 2) =C(2, 2) = 11 C(3, 0) =C(3, 0) = 11 C(3, 1) =C(3, 1) = 33 C(3, 2) =C(3, 2) = 33 C(3, 3) =C(3, 3) = 11 C(4, 0) =C(4, 0) = 11 C(4, 1) =C(4, 1) = 44 C(4, 2) =C(4, 2) = 66 C(4, 3) =C(4, 3) = 44 C(4, 4) =C(4, 4) = 11 kk nn
  • 32. Fall 2002 CMSC 203 - Discrete 32 Binomial CoefficientsBinomial Coefficients Expressions of the form C(n, k) are also calledExpressions of the form C(n, k) are also called binomial coefficientsbinomial coefficients.. How come?How come? AA binomial expressionbinomial expression is the sum of two terms,is the sum of two terms, such as (a + b).such as (a + b). Now consider (a + b)Now consider (a + b)22 = (a + b)(a + b).= (a + b)(a + b). When expanding such expressions, we have toWhen expanding such expressions, we have to form all possible products of a term in the firstform all possible products of a term in the first factor and a term in the second factor:factor and a term in the second factor: (a + b)(a + b)22 = a·a + a·b + b·a + b·b= a·a + a·b + b·a + b·b Then we can sum identical terms:Then we can sum identical terms: (a + b)(a + b)22 = a= a22 + 2ab + b+ 2ab + b22
  • 33. Fall 2002 CMSC 203 - Discrete 33 Binomial CoefficientsBinomial Coefficients For (a + b)For (a + b)33 = (a + b)(a + b)(a + b) we have= (a + b)(a + b)(a + b) we have (a + b)(a + b)33 == aaa + aab + aba + abb + baa + bab + bba + bbbaaa + aab + aba + abb + baa + bab + bba + bbb (a + b)(a + b)33 = a= a33 + 3a+ 3a22 b + 3abb + 3ab22 + b+ b33 There is only one term a3 , because there is only one possibility to form it: Choose a from all three factors: C(3, 3) = 1. There is three times the term a2 b, because there are three possibilities to choose a from two out of the three factors: C(3, 2) = 3. Similarly, there is three times the term ab2 (C(3, 1) = 3) and once the term b3 (C(3, 0) = 1).
  • 34. Fall 2002 CMSC 203 - Discrete 34 Binomial CoefficientsBinomial Coefficients This leads us to the following formula:This leads us to the following formula: j n j jnn bajnCba ∑= − ⋅=+ 0 ),()( With the help of Pascal’s triangle, this formula canWith the help of Pascal’s triangle, this formula can considerably simplify the process of expanding powers ofconsiderably simplify the process of expanding powers of binomial expressions.binomial expressions. For example, the fifth row of Pascal’s triangleFor example, the fifth row of Pascal’s triangle (1 – 4 – 6 – 4 – 1) helps us to compute (a + b)(1 – 4 – 6 – 4 – 1) helps us to compute (a + b)44 :: (a + b)(a + b)44 = a= a44 + 4a+ 4a33 b + 6ab + 6a22 bb22 + 4ab+ 4ab33 + b+ b44 (Binomial Theorem)(Binomial Theorem)