Counting Principles
Counting Principles
1
BASIC COUNTING PRINCIPLES: THE PRODUCT RULE
The Product Rule: A procedure can be broken down into a sequence of two tasks. There are n1 ways to do the
first task and n2 ways to do the second task. Then there are n1∙n2 ways to do the procedure.
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.
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.
Example: An office building contains 27 floors and has 37 offices on each floor. How many offices are in the building?
Solution: By the product rule there are 27 · 37 = 999 offices.
DNA AND GENOMES
• A gene is a segment of a DNA molecule that encodes a particular protein and the entirety of genetic information of an
organism is called its genome.
• DNA molecules consist of two strands of blocks known as nucleotides. Each nucleotide is composed of bases: adenine (A),
cytosine (C), guanine (G), or thymine (T).
• The DNA of bacteria has between 105 and 107 links (one of the four bases). Mammals have between 108 and 1010 links. So,
by the product rule there are at least 4105 different sequences of bases in the DNA of bacteria and 4108 different
sequences of bases in the DNA of mammals.
• The human genome includes approximately 23,000 genes, each with 1,000 or more links.
DNA AND GENOMES
Example: How many 5-element DNA sequences
a) end with A?
b) start with T and end with G?
c) contain only A and T?
d) do not contain C?
Solution: Recall that a DNA sequence is a sequence of letters, each of which is one of A, C, G, or T. Thus by
the product rule there are 45 = 1024 DNA sequences of length five if we impose no restrictions.
a) If the sequence must end with A, then there are only four positions at which to make a choice, so the
answer is 44 = 256.
b) If the sequence must start with T and end with G, then there are only three positions at which to make a
choice, so the answer is 43 = 64.
c) If only two letters can be used rather than four, the number of choices is 25 = 32.
d) As in part (c), there are 35 = 243 sequences that do not contain C.
BASIC COUNTING PRINCIPLES: THE SUM RULE
The Sum Rule: If a task can be done either in one of n1 ways or in one of n2, where none of the set of n1
ways is the same as any of the n2 ways, then there are n1 + n2 ways to do the task.
Example: The mathematics department must choose either a student or a faculty member as a representative
for a university committee. How many choices are there for this representative if there are 37 members of the
mathematics faculty and 83 mathematics majors and no one is both a faculty member and a student.
Solution: By the sum rule it follows that there are 37 + 83 = 120 possible ways to pick a representative.
Example: How many bit strings are there of length six or less?
Solution: We use the sum rule, adding the number of bit strings of each length up to 6. If we include the empty string,
then we get 20 + 21 + 22 + 23 + 24 + 25 + 26 = 27 − 1 = 127
THE SUM AND PRODUCT RULE IN TERMS OF SETS
• The sum rule can be phrased in terms of sets.
|A ∪ B|= |A| + |B| as long as A and B are disjoint sets.
• Or more generally,
|A1 ∪ A2 ∪ ∙∙∙ ∪ Am |= |A1| + |A2| + ∙∙∙ + |Am| when Ai ∩ Aj = ∅ for all i, j.
• 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:
Example: How many license plates can be made using either three digits followed by three uppercase
English letters or four uppercase English letters followed by two digits?
Example: How many bit strings of length eight either start with a 1 bit or end with the two bits 00?
Solution: Use the subtraction rule.
• Number of bit strings of length eight that start with a 1 bit: 27 = 128
• Number of bit strings of length eight that end with bits 00: 26 = 64
• Number of bit strings of length eight that start with a 1 bit and end with
bits 00 : 25 = 32
Hence, the number is 128 + 64 − 32 = 160.
BASIC COUNTING PRINCIPLES: DIVISION RULE
Division Rule: There are n/d ways to do a task if it can be done using a procedure that can be carried out in n ways,
and for every way w, exactly d of the n ways correspond to way w.
• Restated in terms of sets: If the finite set A is the union of n pairwise disjoint subsets each with d elements, then n =
|A|/d.
• In terms of functions: If f is a function from A to B, where both are finite sets, and for every value y ∈ B there are
exactly d values x ∈ A such that f(x) = y, then |B| = |A|/d.
Example: How many ways are there to seat four people around a circular table, where two seatings are considered
the same when each person has the same left and right neighbor?
Solution: Number the seats around the table from 1 to 4 proceeding clockwise. There are four ways to select the
person for seat 1, 3 for seat 2, 2, for seat 3, and one way for seat 4. Thus there are 4! = 24 ways to order the four
people. But since two seatings are the same when each person has the same left and right neighbor, for every choice
for seat 1, we get the same seating.
Therefore, by the division rule, there are 24/4 = 6 different seating arrangements.
TREE DIAGRAMS
• Tree Diagrams: We can solve many counting problems through the use of tree diagrams, where a branch represents
a possible choice and the leaves represent possible outcomes.
• Example: Suppose that “I Love Ashesi” T-shirts come in five different sizes: S,M,L,XL, and XXL. Each size comes in four
colors (white, red, green, and black), except XL, which comes only in red, green, and black, and XXL, which comes only
in green and black. What is the minimum number of shirts that the campus store needs to stock to have one of each
size and color available?
• Solution: Draw the tree diagram.
Pigeonhole Principle: If k is a positive integer and k + 1 objects are placed into k boxes, then at least one
box contains two or more objects.
Proof: We use a proof by contraposition. Suppose none of the k boxes has more than one object. Then the
total number of objects would be at most k. This contradicts the statement that we have k + 1 objects.
THE PIGEONHOLE PRINCIPLE
Example: Among any group of 367 people, there must be at least two with the same birthday.
Solution: True because there are only 366 possible birthdays.
Example: Suppose that there are nine students in a discrete maths class at a small college.
a) Show that the class must have at least five male students or at least five female students.
b) Show that the class must have at least three male students or at least seven female students.
Solution: a) If not, then there would be 4 or fewer male students and 4 or fewer female students,
so there would be 4 + 4 = 8 or fewer students in all, contradicting the assumption that there are
9 students in the class.
b) If not, then there would be 2 or fewer male students and 6 or fewer female students, so there
would be 2 + 6 = 8 or fewer students in all, contradicting the assumption that there are 9
students in the class.
THE GENERALIZED PIGEONHOLE PRINCIPLE
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.
Proof: We use a proof by contraposition. Suppose that none of the boxes contains more than ⌈N/k⌉ − 1
objects. Then the total number of objects is at most
where the inequality ⌈N/k⌉ < ⌈N/k⌉ + 1 has been used. This is a contradiction because there are a total of N
objects.
Example: Among 100 people there are at least ⌈100/12⌉ = 9 who were born in the same month.
THE GENERALIZED PIGEONHOLE PRINCIPLE
Example: a) How many cards must be selected from a standard deck of 52 cards to guarantee that at least three
cards of the same suit are chosen?
b) How many must be selected to guarantee that at least three hearts are selected?
Solution: a) We assume four boxes; one for each suit. Using the generalized pigeonhole principle, at least one box
contains at least ⌈N/4⌉ cards. At least three cards of one suit are selected if ⌈N/4⌉ ≥3. The smallest integer N such that
⌈N/4⌉ ≥3 is N = 2 ∙ 4 + 1 = 9.
b) A deck contains 13 hearts and 39 cards which are not hearts. So, if we select 41 cards, we may have 39 cards
which are not hearts along with 2 hearts. However, when we select 42 cards, we must have at least three hearts. (Note
that the generalized pigeonhole principle is not used here.)
THE GENERALIZED PIGEONHOLE PRINCIPLE
Example: A bowl contains 10 red balls and 10 blue balls. A woman selects balls at random without looking at them.
a) How many balls must she select to be sure of having at least three balls of the same color?
b) How many balls must she select to be sure of having at least three blue balls?
Solution: We assume that the woman does not replace the balls after drawing them.
a) There are two colors: these are the pigeonholes. We want to know the least number of pigeons needed to insure that at
least one of the pigeonholes contains three pigeons. By the generalized pigeonhole principle, the answer is 5. If five
balls are selected, at least ⌈ 5/2 ⌉ = 3 must have the same color.
On the other hand four balls is not enough, because two might be red and two might be blue. Note that the number of
balls was irrelevant (assuming that it was at least 5).
b) She needs to select 13 balls in order to insure at least three blue ones. If she does so, then at most 10 of them are red,
so at least three are blue. On the other hand, if she selects 12 or fewer balls, then 10 of them could be red, and she might
not get her three blue balls. This time the number of balls did matter.