Basic Counting Principles
January 21, 2025
Combinatorics
Basic Counting Principles
Counting problems may be hard, and easy solutions are not
obvious.
Approach : – simplify the solution by decomposing the
problem.
Combinatorics
Basic Counting Principles
Counting problems may be hard, and easy solutions are not
obvious.
Approach : – simplify the solution by decomposing the
problem.
Combinatorics
Four basic counting principles :
1 The product rule : The product rule applies when a procedure
is made up of separate tasks - A count decomposes into a
sequence of dependent counts (“each element in the first count
is associated with all elements of the second count”)
2 The sum rule : A count decomposes into a set of independent
counts (“elements of counts are alternatives”).
3 The subtraction rule : A counting technique that removes
certain possibilities from a total set to find the number of ways
to select items.
4 The Division rule : A acounting technique that is used to find
the number of groups in a set when the groups are equal in
size.
Combinatorics
Four basic counting principles :
1 The product rule : The product rule applies when a procedure
is made up of separate tasks - A count decomposes into a
sequence of dependent counts (“each element in the first count
is associated with all elements of the second count”)
2 The sum rule : A count decomposes into a set of independent
counts (“elements of counts are alternatives”).
3 The subtraction rule : A counting technique that removes
certain possibilities from a total set to find the number of ways
to select items.
4 The Division rule : A acounting technique that is used to find
the number of groups in a set when the groups are equal in
size.
Combinatorics
Four basic counting principles :
1 The product rule : The product rule applies when a procedure
is made up of separate tasks - A count decomposes into a
sequence of dependent counts (“each element in the first count
is associated with all elements of the second count”)
2 The sum rule : A count decomposes into a set of independent
counts (“elements of counts are alternatives”).
3 The subtraction rule : A counting technique that removes
certain possibilities from a total set to find the number of ways
to select items.
4 The Division rule : A acounting technique that is used to find
the number of groups in a set when the groups are equal in
size.
Combinatorics
Four basic counting principles :
1 The product rule : The product rule applies when a procedure
is made up of separate tasks - A count decomposes into a
sequence of dependent counts (“each element in the first count
is associated with all elements of the second count”)
2 The sum rule : A count decomposes into a set of independent
counts (“elements of counts are alternatives”).
3 The subtraction rule : A counting technique that removes
certain possibilities from a total set to find the number of ways
to select items.
4 The Division rule : A acounting technique that is used to find
the number of groups in a set when the groups are equal in
size.
Combinatorics
Product Rule
Suppose that a procedure can be broken into a sequence of
two tasks.
Assume there are n1 ways to do the first task.
Assume for each of these ways of doing the first task, there are
n2 ways to do the second task.
So, there are n1 n2 ways to do the procedure.
Combinatorics
Product Rule
Suppose that a procedure can be broken into a sequence of
two tasks.
Assume there are n1 ways to do the first task.
Assume for each of these ways of doing the first task, there are
n2 ways to do the second task.
So, there are n1 n2 ways to do the procedure.
Combinatorics
Product Rule
Suppose that a procedure can be broken into a sequence of
two tasks.
Assume there are n1 ways to do the first task.
Assume for each of these ways of doing the first task, there are
n2 ways to do the second task.
So, there are n1 n2 ways to do the procedure.
Combinatorics
Product Rule
Suppose that a procedure can be broken into a sequence of
two tasks.
Assume there are n1 ways to do the first task.
Assume for each of these ways of doing the first task, there are
n2 ways to do the second task.
So, there are n1 n2 ways to do the procedure.
Combinatorics
Extended version of the product rule:
A procedure can be broken down into a sequence of tasks
T1 , T2 , · · · , Tm .
Assume each task Ti (i = 1, 2, · · · , m), can be done in ni
different ways, regardless of how the previous tasks were done.
The procedure can be done in n1 × n2 × · · · × nm different ways.
Combinatorics
Product Rule in Terms of Sets
If A1 , A2 , · · · , Am are finite sets, then the number of elements in
the Cartesian product of these sets is the product of the
number of elements of each set.
The task of choosing an element in the Cartesian product
A1 × A2 × · · · × Am is done by choosing an element in A1 , an
element in A2 , · · · , and an element in Am .
By the product rule, it follows that:
|A1 × A2 × · · · × Am | = |A1 | × |A2 | × · · · × |Am |.
Combinatorics
Example 1
Example
How many bit strings of length seven are there?
Solution: Since each of the seven bits is either a "0" or a "1",
the answer is 27 = 128.
Combinatorics
Example 1
Example
How many bit strings of length seven are there?
Solution: Since each of the seven bits is either a "0" or a "1",
the answer is 27 = 128.
Combinatorics
Example 2
Example
How many different license plates can be made if each plate
contains a sequence of three uppercase English letters
followed by three digits?
Solution: By the product rule, there are
26 × 26 × 26 × 10 × 10 × 10 = 17, 576, 000. different possible
license plates.
Combinatorics
Example 2
Example
How many different license plates can be made if each plate
contains a sequence of three uppercase English letters
followed by three digits?
Solution: By the product rule, there are
26 × 26 × 26 × 10 × 10 × 10 = 17, 576, 000. different possible
license plates.
Combinatorics
Example 3
Example
Counting Functions: How many functions are there from a
set with m elements to a set with n elements?
A function represents a choice of one of the n elements of the
codomain for each of the m elements in the domain.
1 Let A = {a1 , a2 , · · · , am } represent the domain of f .
2 Let B = {b1 , b2 , · · · , bn } represent the co-domain of f .
3 Let f : A → B.
4 Since f is a function, for each bi in B there are n possible
(aj′ s) choices of assignment.
5 Hence, the product rule tells us that there are
n × n × · · · × n = nm such functions.
Combinatorics
Example 3
Example
Counting Functions: How many functions are there from a
set with m elements to a set with n elements?
A function represents a choice of one of the n elements of the
codomain for each of the m elements in the domain.
1 Let A = {a1 , a2 , · · · , am } represent the domain of f .
2 Let B = {b1 , b2 , · · · , bn } represent the co-domain of f .
3 Let f : A → B.
4 Since f is a function, for each bi in B there are n possible
(aj′ s) choices of assignment.
5 Hence, the product rule tells us that there are
n × n × · · · × n = nm such functions.
Combinatorics
Example 3
Example
Counting Functions: How many functions are there from a
set with m elements to a set with n elements?
A function represents a choice of one of the n elements of the
codomain for each of the m elements in the domain.
1 Let A = {a1 , a2 , · · · , am } represent the domain of f .
2 Let B = {b1 , b2 , · · · , bn } represent the co-domain of f .
3 Let f : A → B.
4 Since f is a function, for each bi in B there are n possible
(aj′ s) choices of assignment.
5 Hence, the product rule tells us that there are
n × n × · · · × n = nm such functions.
Combinatorics
Example 3
Example
Counting Functions: How many functions are there from a
set with m elements to a set with n elements?
A function represents a choice of one of the n elements of the
codomain for each of the m elements in the domain.
1 Let A = {a1 , a2 , · · · , am } represent the domain of f .
2 Let B = {b1 , b2 , · · · , bn } represent the co-domain of f .
3 Let f : A → B.
4 Since f is a function, for each bi in B there are n possible
(aj′ s) choices of assignment.
5 Hence, the product rule tells us that there are
n × n × · · · × n = nm such functions.
Combinatorics
Example 3
Example
Counting Functions: How many functions are there from a
set with m elements to a set with n elements?
A function represents a choice of one of the n elements of the
codomain for each of the m elements in the domain.
1 Let A = {a1 , a2 , · · · , am } represent the domain of f .
2 Let B = {b1 , b2 , · · · , bn } represent the co-domain of f .
3 Let f : A → B.
4 Since f is a function, for each bi in B there are n possible
(aj′ s) choices of assignment.
5 Hence, the product rule tells us that there are
n × n × · · · × n = nm such functions.
Combinatorics
Example 3
Example
Counting Functions: How many functions are there from a
set with m elements to a set with n elements?
A function represents a choice of one of the n elements of the
codomain for each of the m elements in the domain.
1 Let A = {a1 , a2 , · · · , am } represent the domain of f .
2 Let B = {b1 , b2 , · · · , bn } represent the co-domain of f .
3 Let f : A → B.
4 Since f is a function, for each bi in B there are n possible
(aj′ s) choices of assignment.
5 Hence, the product rule tells us that there are
n × n × · · · × n = nm such functions.
Combinatorics
Example 3
Example
Counting Functions: How many functions are there from a
set with m elements to a set with n elements?
A function represents a choice of one of the n elements of the
codomain for each of the m elements in the domain.
1 Let A = {a1 , a2 , · · · , am } represent the domain of f .
2 Let B = {b1 , b2 , · · · , bn } represent the co-domain of f .
3 Let f : A → B.
4 Since f is a function, for each bi in B there are n possible
(aj′ s) choices of assignment.
5 Hence, the product rule tells us that there are
n × n × · · · × n = nm such functions.
Combinatorics
Example 4
Example
Counting One-to-One Functions: How many one-to-one
functions are there from a set with m elements to one with n
elements?
Solution: Let f : A → B.
1 Let A = {a1 , a2 , · · · , am } represent the domain of f .
2 There are n ways to choose the value of a1 and n − 1 ways
to choose a2 , etc.
3 The product rule tells us that there are
n(n − 1)(n − 2) · · · (n − m + 1) such functions.
Combinatorics
Example 4
Example
Counting One-to-One Functions: How many one-to-one
functions are there from a set with m elements to one with n
elements?
Solution: Let f : A → B.
1 Let A = {a1 , a2 , · · · , am } represent the domain of f .
2 There are n ways to choose the value of a1 and n − 1 ways
to choose a2 , etc.
3 The product rule tells us that there are
n(n − 1)(n − 2) · · · (n − m + 1) such functions.
Combinatorics
Example 4
Example
Counting One-to-One Functions: How many one-to-one
functions are there from a set with m elements to one with n
elements?
Solution: Let f : A → B.
1 Let A = {a1 , a2 , · · · , am } represent the domain of f .
2 There are n ways to choose the value of a1 and n − 1 ways
to choose a2 , etc.
3 The product rule tells us that there are
n(n − 1)(n − 2) · · · (n − m + 1) such functions.
Combinatorics
Example 4
Example
Counting One-to-One Functions: How many one-to-one
functions are there from a set with m elements to one with n
elements?
Solution: Let f : A → B.
1 Let A = {a1 , a2 , · · · , am } represent the domain of f .
2 There are n ways to choose the value of a1 and n − 1 ways
to choose a2 , etc.
3 The product rule tells us that there are
n(n − 1)(n − 2) · · · (n − m + 1) such functions.
Combinatorics
Example 4
Example
Counting One-to-One Functions: How many one-to-one
functions are there from a set with m elements to one with n
elements?
Solution: Let f : A → B.
1 Let A = {a1 , a2 , · · · , am } represent the domain of f .
2 There are n ways to choose the value of a1 and n − 1 ways
to choose a2 , etc.
3 The product rule tells us that there are
n(n − 1)(n − 2) · · · (n − m + 1) such functions.
Combinatorics
Example 5
Example
Use the product rule to show that the number of different
subsets of a finite set S is 2|S| .
Solution:
1 List the elements of S = {a1 , a2 , · · · , an }.
2 To form a subset A, we decide if A includes element ai
from S or not where 1 ≤ i ≤ |S|.
3 Task i: Decide if A contains ai or not.
4 By the product rule, there are 2|S| different subsets, in
other words, |P(S)| = 2|S| .
Combinatorics
Example 5
Example
Use the product rule to show that the number of different
subsets of a finite set S is 2|S| .
Solution:
1 List the elements of S = {a1 , a2 , · · · , an }.
2 To form a subset A, we decide if A includes element ai
from S or not where 1 ≤ i ≤ |S|.
3 Task i: Decide if A contains ai or not.
4 By the product rule, there are 2|S| different subsets, in
other words, |P(S)| = 2|S| .
Combinatorics
Example 5
Example
Use the product rule to show that the number of different
subsets of a finite set S is 2|S| .
Solution:
1 List the elements of S = {a1 , a2 , · · · , an }.
2 To form a subset A, we decide if A includes element ai
from S or not where 1 ≤ i ≤ |S|.
3 Task i: Decide if A contains ai or not.
4 By the product rule, there are 2|S| different subsets, in
other words, |P(S)| = 2|S| .
Combinatorics
Example 5
Example
Use the product rule to show that the number of different
subsets of a finite set S is 2|S| .
Solution:
1 List the elements of S = {a1 , a2 , · · · , an }.
2 To form a subset A, we decide if A includes element ai
from S or not where 1 ≤ i ≤ |S|.
3 Task i: Decide if A contains ai or not.
4 By the product rule, there are 2|S| different subsets, in
other words, |P(S)| = 2|S| .
Combinatorics
Example 5
Example
Use the product rule to show that the number of different
subsets of a finite set S is 2|S| .
Solution:
1 List the elements of S = {a1 , a2 , · · · , an }.
2 To form a subset A, we decide if A includes element ai
from S or not where 1 ≤ i ≤ |S|.
3 Task i: Decide if A contains ai or not.
4 By the product rule, there are 2|S| different subsets, in
other words, |P(S)| = 2|S| .
Combinatorics
Example 5
Example
Use the product rule to show that the number of different
subsets of a finite set S is 2|S| .
Solution:
1 List the elements of S = {a1 , a2 , · · · , an }.
2 To form a subset A, we decide if A includes element ai
from S or not where 1 ≤ i ≤ |S|.
3 Task i: Decide if A contains ai or not.
4 By the product rule, there are 2|S| different subsets, in
other words, |P(S)| = 2|S| .
Combinatorics
Sum rule
The sum rule:
Assume a task can be done either in one of n1 ways or in one
of n2 ways.
Assume none of the set of n1 ways is the same as any of the
set n2 ways.
So, there are n1 + n2 ways to do the task.
Combinatorics
Sum rule for sets
1 Let S1 , S2 , · · · , Sk be a partition of a finite set S.
2 (i.e.) S = S1 ∪ S2 ∪ · · · Sk and Si ∩ Sj = ∅ for i ̸= j.
3 The addition principle claims that in this case :
|S| = |S1 | + |S2 | + · · · + |Sk |
Combinatorics
Sum rule for sets
1 Let S1 , S2 , · · · , Sk be a partition of a finite set S.
2 (i.e.) S = S1 ∪ S2 ∪ · · · Sk and Si ∩ Sj = ∅ for i ̸= j.
3 The addition principle claims that in this case :
|S| = |S1 | + |S2 | + · · · + |Sk |
Combinatorics
Sum rule for sets
1 Let S1 , S2 , · · · , Sk be a partition of a finite set S.
2 (i.e.) S = S1 ∪ S2 ∪ · · · Sk and Si ∩ Sj = ∅ for i ̸= j.
3 The addition principle claims that in this case :
|S| = |S1 | + |S2 | + · · · + |Sk |
Combinatorics
Example 1
Example
Let S be the set of students attending the combinatorics
lecture.
1 S can be partitioned into parts S1 and S2 .
2 S1 is the set of students that like easy examples.
3 S2 is the set of students that don’t like easy examples.
4 If |S1 | = 22 and |S2 | = 8 then we can conclude |S| = 30.
Combinatorics
Example 1
Example
Let S be the set of students attending the combinatorics
lecture.
1 S can be partitioned into parts S1 and S2 .
2 S1 is the set of students that like easy examples.
3 S2 is the set of students that don’t like easy examples.
4 If |S1 | = 22 and |S2 | = 8 then we can conclude |S| = 30.
Combinatorics
Example 1
Example
Let S be the set of students attending the combinatorics
lecture.
1 S can be partitioned into parts S1 and S2 .
2 S1 is the set of students that like easy examples.
3 S2 is the set of students that don’t like easy examples.
4 If |S1 | = 22 and |S2 | = 8 then we can conclude |S| = 30.
Combinatorics
Example 1
Example
Let S be the set of students attending the combinatorics
lecture.
1 S can be partitioned into parts S1 and S2 .
2 S1 is the set of students that like easy examples.
3 S2 is the set of students that don’t like easy examples.
4 If |S1 | = 22 and |S2 | = 8 then we can conclude |S| = 30.
Combinatorics
Example 2
Example
Assume there are 37 members of the mathematics faculty and
83 mathematics majors. Suppose that either a member of the
mathematics faculty or a student who is a mathematics major is
chosen as a representative to a university committee. How
many different ways to choose this representative?
Combinatorics
Solution 2
Solution :
1 There are 37 ways to choose a faculty member.
2 There are 83 ways to choose a student.
3 By the sum rule, there are 37 + 83 = 120 different ways to
choose such a representative.
Combinatorics
Solution 2
Solution :
1 There are 37 ways to choose a faculty member.
2 There are 83 ways to choose a student.
3 By the sum rule, there are 37 + 83 = 120 different ways to
choose such a representative.
Combinatorics
Solution 2
Solution :
1 There are 37 ways to choose a faculty member.
2 There are 83 ways to choose a student.
3 By the sum rule, there are 37 + 83 = 120 different ways to
choose such a representative.
Combinatorics
Example 3
Example
Suppose statement labels in a programming language can be
either a single letter or a letter followed by a digit. Find the
number of possible labels.
Solution : Use the product rule.
26 + (26 × 10) = 286.
Combinatorics
Example 4
Example
Each user on a computer system has a password, which is six
to eight characters long, where each character is an uppercase
letter or a digit. Each password must contain at least one digit.
How many possible passwords are there?
Solution : Let P be the total number of passwords, and let P6 ,
P7 , and P8 be the passwords of length 6, 7, and 8.
Combinatorics
Solution 4
By the sum rule P = P6 + P7 + P8 .
To find each of P6 , P7 , and P8 , we find the number of
passwords of the specified length composed of letters and
digits and subtract the number composed only of letters.
We find that:
P6 = 366 − 266 .
P7 = 367 − 267 .
P8 = 368 − 268 .
Consequently,
P = P6 + P7 + P8 = 366 + 367 + 368 − (266 + 267 + 268 ).
Combinatorics
Example 5
Example
On the internet, each computer is assigned an internet
address.
1 An address is a string of 32 bits. It begins with a network
number (net id) followed by a host number (host id).
2 Class A addresses consists of 0, followed by a 7-bit net id
and a 24-bit host id.
3 Class B addresses consists of 10, followed by a 14-bit net
id and a 16-bit host id. host id.
4 There are several restrictions: 1111111 is not available as
the net id of a class A network.
5 Host ids do not consists of all 0s and all 1s are not
available for use in any network.
How many different addresses are available for computers on
the Internet?
Combinatorics
Solution 5
Solution :
1 Class A : Since the net id of class A cannot be 1111111, the
number of Class A net ids is 27 − 1. Since the hostid cannot
consist all 0’s and all 1’s, the number of Class A hostids is
224 − 2. By the product rule, the number of task 1 is
(27 − 1)(224 − 2)
2 Class B : By the product rule, the number of Class B net ids is
214 . Since the host id cannot consist all 0’s and all 1’s, the
number of Class B host ids is 216 − 2. By the product rule, the
number of task 2 is
214 (216 − 2)
By the sum product, the number of Internet addresses are the
number of Class A + the number of Class B.
Combinatorics
Subtraction Rule
Let A be a set and let U be a larger set containing A.
Let Ā = U \ A = {x ∈ U : x ∈
/ A} be the complement of A in U.
Then, the number |A| of objects in A is given by the rule
|Ā| = |U| − |A|
Combinatorics
Example 1
Example
Computer passwords are to consist of a string of six symbols
taken from the digits 0, 1, 2, · · · , 9 and the lowercase letters
a, b, c, · · · , z. How many computer passwords have a repeated
symbol?
Solution : Use the subtraction rule.
1 Let A be the set of all computer passwords with a repeated
symbol.
2 Let U be the set of all computer passwords.
3 Taking the complement of A in U we get the set Ā of
computer passwords with no repeated symbols.
Combinatorics
Example 1
Example
Computer passwords are to consist of a string of six symbols
taken from the digits 0, 1, 2, · · · , 9 and the lowercase letters
a, b, c, · · · , z. How many computer passwords have a repeated
symbol?
Solution : Use the subtraction rule.
1 Let A be the set of all computer passwords with a repeated
symbol.
2 Let U be the set of all computer passwords.
3 Taking the complement of A in U we get the set Ā of
computer passwords with no repeated symbols.
Combinatorics
Solution Contd..
Number of passwords of length six : |U| = (26 + 10)6 = 366
Number of computer passwords with no repeated
symbols : |Ā| = 36 × 35 × 33 × 32 × 31
Number of computer passwords with repeated symbols
: |A| = |U| − |Ā| = 366 − (36 × 35 × 33 × 32 × 31)
Combinatorics
Solution Contd..
Number of passwords of length six : |U| = (26 + 10)6 = 366
Number of computer passwords with no repeated
symbols : |Ā| = 36 × 35 × 33 × 32 × 31
Number of computer passwords with repeated symbols
: |A| = |U| − |Ā| = 366 − (36 × 35 × 33 × 32 × 31)
Combinatorics
Solution Contd..
Number of passwords of length six : |U| = (26 + 10)6 = 366
Number of computer passwords with no repeated
symbols : |Ā| = 36 × 35 × 33 × 32 × 31
Number of computer passwords with repeated symbols
: |A| = |U| − |Ā| = 366 − (36 × 35 × 33 × 32 × 31)
Combinatorics
Division Principle
1 Let S be finite set.
2 S = S1 ∪ S2 ∪ · · · Sk ,
3 Si ∩ Sj = ∅ for all i ̸= j.
4 |Si | = m for all 1 ≤ i ≤ k .
Then, the number of parts in the partition is given by the rule
|S|
k=
m
number of objects in a part.
Thus, we can determine the number of parts if we know the
number of objects in S and the common value of the number of
objects in the parts.
Combinatorics
Example
There are 740 pigeons in a collection of pigeonholes. If each
pigeonhole contains 5 pigeons, the number of pigeonholes
equals
740
= 148
5
Combinatorics