Thanks to visit codestin.com
Credit goes to www.scribd.com

0% found this document useful (0 votes)
59 views11 pages

Fundamentals of Counting Rules

This document introduces fundamental counting principles including the sum rule, product rule, and inclusion-exclusion principle. It provides examples of applying these principles to problems involving counting choices from sets and sequences. The key topics covered are enumerating strings, passwords, and integers that satisfy certain criteria. Examples also demonstrate combining rules and using indirect counting methods.
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
59 views11 pages

Fundamentals of Counting Rules

This document introduces fundamental counting principles including the sum rule, product rule, and inclusion-exclusion principle. It provides examples of applying these principles to problems involving counting choices from sets and sequences. The key topics covered are enumerating strings, passwords, and integers that satisfy certain criteria. Examples also demonstrate combining rules and using indirect counting methods.
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 11

1

Introduction to Counting

1.1

Introduction

In this chapter you will learn the fundamentals of enumerative combinatorics, the branch of
mathematics concerned with counting. While enumeration problems can be arbitrarily difficult,
the fundamentals are easy to master and will prepare you for the more difficult problems ahead.
You will be surprised at the degree of difficulty of the problems that you can solve using only
these simple tools. Our goal is that this chapter be sufficient to meet the needs of students
in MA1025, but some of you might want additional reading material or additional exercises.
There are currently two copies of Discrete Mathematics and Its Applications, by Kenneth
Rosen, on two-hour reserve in the library for the studetns in MA2025. By now, all of those
students have their own copies, so it should be available. If you want more to read, and more
problems to work, it is a good choice. The material in this chapter corresponds to Section
5.1, and Section 5.2 through page 335. A number of problems can be found at the end of this
chapter. You will also find a list of suggested exercises from the Rosen text.
Upon completion of this chapter, you will have mastered the following:
The Sum Rule
The Product Rule
The basic Inclusion-Exclusion Principle
You will also encounter a device called a tree diagram and a tool colloquially known as the
Pigeonhole Principle, but the first is infrequently used and the second shows up in some very
difficult problems, so I dont think mastery of those tools is the goal.

1.2

Overview and Definitions

The sum rule tells us in how many ways one can make a single choice from two disjoint
sets of alternatives. The product rule tells us in how many ways one can make one choice
from each of two sets of alternatives. Both rules generalize to larger families of sets. The
basic Principle of Inclusion-Exclusion extends the sum rule to situations in which the two sets
of alternatives are not disjoint. This, too, generalizes to larger collections of sets. A finite
sequence of choices can be represented by a tree diagram, in which the root represents the
initial state, leaves represent outcomes, internal vertices represent intermediate states, and
edges represent choices. The Pigeonhole Principle, in its picturesque form, says that if k + 1
pigeons fly into k pigeonholes, at least one pigeonhole must contain at least two pigeons.

1.3

The Sum and Product Rules

The most fundamental rules are the Sum Rule and the Product Rule.
Theorem 1 (Sum Rule) If A B = , then |A B| = |A| + |B|.
Although the sum rule tells us that the cardinality of the union of two disjoint sets is
the sum of the cardinalities of the two sets, it is typically applied to problems that do not
immediately remind us of sets.
Example 1: Suppose that you are in a restaurant, and are going to have either soup or
salad but not both. There are two soups and four salads on the menu. How many choices do
you have? By the Sum Rule, you have 2 + 4 = 6 choices.
Theorem 2 (Product Rule) For any choice of sets A and B, |A B| = |A||B|.
The product rule tells us that the cardinality of the Cartesian Product of two sets is the
product of the cardinality of the two sets. Back in that same restaurant, there are 2 4 = 8
ways to have both soup and salad. Both rules generalize to larger numbers of sets, although
the generalization of the sum rule requires that the sets in question are pairwise disjoint.
Example 2: The first two of these problems apply the generalized Product Rule. We
begin with a couple of definitions: An alphabet is a finite set of symbols. A string of length k
over an alphabet A is a finite sequence a1 a2 ...ak of symbols from A, with repetition allowed.
(a) How many distinguishable strings of length 3 over the alphabet {A, B, . . . , Z} exist?
Solution: Since there are 26 choices for the first symbol, 26 for the second, and 26 for
the third, then by the Product Rule there are 263 = 17576 such strings of length 3.
(b) How many strings of length 4 over the alphabet {0, 1, . . . , 9} do not begin with 0?
Solution: There are nine choices for the first symbol, and ten for each of the second,
third, and fourth. By the Product Rule, there are 9 103 = 9000 strings of length 4 that
do not begin with 0. (Note: this is also the number of 4-digit positive integers with no
leading zeros.)
(c) The standard California license-plate number begins with a nonzero decimal digit that is
followed by three uppercase alpha characters, which are in turn followed by three decimal
digits. How many of these license numbers exist?
Solution: By the preceding problems and the basic Product Rule, there are
9 263 103 = 158184000
such numbers. The fact that we are inserting the string of alpha characters between the
first and second digits of the string of decimal digits has no effect on the count.
2

Its hard to argue that these are anything but the simplest of rules. By using these rules
in combination, you can do quite a bit, but you should expect to find the degree of difficulty
rising. Sometimes the added difficulty is simply a matter of bookkeeping, but it can also take
the form of additional subtlety.
Example 3: We combine the sum and product rules, and introduce a new tool, to find
the number of passwords adhering to some simple constraints. The length must be at least 5
and at most 7. The password must be constructed of uppercase alpha characters and decimal
digits, and must contain at least one digit. By the sum rule, the total number P is given by
P = P5 + P6 + P7 , where Pi is the number of legal passwords of length i. But what is P5 ?
The number of digits in a legal password of length 5 could be as small as 1 or as large as 5,
so it appears that we must compute five numbers and find their sum. But notice that the
number of illegal passwords of length 5 is easy to count: there are 265 of these. It follows that
P5 = 365 265 = 48584800. This is an example of indirect counting: to find the number of
ways to perform a task in the presence of constraints, we instead count the number of ways
to perform the task with no constraints and subtract from it the number of ways to perform
the task while violating those constraints. This method is sometimes easier, and should not
be overlooked. We can use the same approach to find P6 = 366 266 = 1867866560 and
P7 = 367 267 = 70332353920, and the problem is solved: there are
P5 + P6 + P7 = 72248805280
acceptable passwords.
Example 4:
(a) How many integers x with 1 x 11 are divisible by 2?
Solution: b 11
c = 5.
2
(b) How many integers x with 1 x 11 are not divisible by 2?
Solution: We use indirect counting by subtracting those that are divisible by 2 from
total number of integers: 11 b 11
c = 6.
2

1.4

The Principle of Inclusion-Exclusion

The Principle of Inclusion-Exclusion is the principle that lets us generalize the Sum Rule
by counting unions of sets that are not necessarily pairwise disjoint. The basic instance of the
principle applies to unions of two sets. The idea is simple: we already know that if two sets
A and B are disjoint, the cardinality of their union is simply |A B| = |A| + |B|. Suppose,
though, that A B 6= . If x A B, then x is counted twice in |A| + |B|: once in |A| and
3

once in |B|. This applies to every element in A B, so we must subtract |A B| to correct


the overcount. The principle, then, tells us that
|A B| = |A| + |B| |A B|.
Example 5: The following four problems apply the principle of inclusion-exclusion.
(a) Let A = {1, 2, 3, 4, 5} and B = {3, 4, 5, 6, 7}. Then A B = {1, 2, 3, 4, 5, 6, 7}. By
inspection, |A B| = 7, but you can also verify that
|A B| = 7 = 5 + 5 3 = |A| + |B| |A B|.
(b) How many positive integers not bigger than 20 are divisible by either 2 or 3?
Solution: There are b20/2c = 10 that are divisible by 2, and b20/3c = 6 that are
divisible by 3. But there are also b20/6c = 3 that are divisible by both 2 and 3, so the
total is 10 + 6 3 = 13.
(c) How many bitstrings of length eight either begin with 00 or end with 101?
Solution: There are 26 that begin with 00, 25 that end with 101, and 23 that start with
00 and end with 101. So the number of bitstrings with at least one of the two properties
is 26 + 25 23 = 88.
You can probably convince yourself that the inclusion-exclusion formula for the cardinality
of the union of three sets is
|A B C| = |A| + |B| + |C| |A B| |A C| |B C| + |A B C|.
The principle generalizes to more than three sets, and there is an inductive proof of that
generalization.

1.5

Tree Diagrams

A tree diagram offers a way to enumerate outcomes resulting from a finite (and preferably
small) sequence of choices. Each vertex represents a state, with the initial state represented by
the root and the outcomes represented by the leaves. Edges tending downward from a vertex
represent choices. Figure 1 shows a decision tree used to enumerate bitstrings of length three
that do not contain 11. The leaves, from left to right, represent the strings 101, 100, 010, 001,
and 000. You can see that any branch containing two consecutive 1s has been pruned out,
leaving only those that do not contain 11. And you can probably guess that the utility of tree
diagrams, like that of truth tables and Venn diagrams, is limited to small problems. On the
other hand, the tree structure lends itself to computation, so you will probably see this again.
4

root
t
1
t

t
A
1 A 0
t
At

@0
@t
@

@ 0
t
@t

A
0 1 A 0
t
t
At

Figure 1: A decision tree for counting 11-free strings

1.6

The Pigeonhole Principle

The Pigeonhole Principle has as picturesque a statement as any in combinatorics, and in


its most basic form the proof is so intuitive as to be obvious. But there are many forms to this
principle, and putting it to use can be arduous. Our focus is on relatively easy applications of
the principle. Here it is in its simple form:
Theorem 3 (The Simplified Pigeonhole Principle) If k pigeons occupy k 1 pigeonholes, then
at least one pigeonhole contains at least two pigeons.
A more useful presentation is the following:
Theorem 4 (The Pigeonhole Principle) If k pigeons occupy j < k pigeonholes, then at least
one pigeonhole contains at least two pigeons.
This can be restated in terms of functions: If A and B are sets, and if |A| > |B|, then
there can be no one-to-one mapping f : A B. The proof is straightforward. In applying the
principle, the difficulty (when there is one) is in deciding what constitutes a pigeonhole and
what constitutes a pigeon.
Example 6:
(a) The hello, world problem for the pigeonhole principle is the sock problem: In your
dresser drawer you have a jumble of socks in two colors, say blue and gray. Its dark,
and you dont want to wake your spouse. How many socks must you grab to guarantee
that you have a pair of the same color?
Solution: Three socks suffice. You might end up with three blue, or three gray, but
with only two colors youre guaranteed to have at least two blue or at least two gray.
That is, the pigeonholes are the colors, the the pigeons are the socks. As you draw one
sock from the drawer, you put it in the respective pigeonhole, and one pigeonhole will
have at least two socks.
5

(b) Show that in a group of eight people there must be two whose birthdays fall on the same
day of the week.
Solution: The pigeons are now the people in the group, and the pigeonholes are the
days of the week.
(c) Show that in a group of ten people there must be two whose birthdays fall on the same
day of the week.
Solution: The pigeons are now the people in the group, and the pigeonholes are the
days of the week.
(d) Show that if five integers are selected from the set A = {1, 2, 3, 4, 5, 6, 7, 8}, there must
be two whose sum is 9.
Solution: Consider the four pairs {1, 8}, {2, 7}, {3, 6}, and {4, 5}. Those are the pigeonholes. The pigeons are the five selected integers. Two must be elements of the same
pigeonhole.
A generalization of the principle is this:
Theorem 5 If n pigeons occupy k pigeonholes, then at least one pigeonhole contains at least
dn/ke pigeons.
We can use this version to answer more difficult questions. What is the smallest n such that
at least one of k boxes must contain at least r of n objects? By Theorem 4, we need dn/ke r.
So the smallest integer n that forces some box to contain r of n objects is n = k(r 1) + 1.
How can you avoid having at least r objects in some box? By setting n < r, of course. But
by setting n k(r 1), you stand a chance at having fewer than r objects in every box.
Example 7:
(a) In your dresser drawer you have a jumble of socks in two colors, say blue and gray. Its
dark, and you dont want to wake your spouse. How many socks must you grab to
guarantee that you have 3 socks of the same color?
Solution: Five socks suffice. You might end up with more than three blue, or three gray,
but with only two colors youre guaranteed to have at least three blue or at least three
gray. That is, the pigeonholes are the colors, the the pigeons are the socks. As you draw
one sock from the drawer, you put it in the respective pigeonhole, and one pigeonhole
will have at least three socks.
(b) Show that in a group of 25 people there must be four whose birthdays fall on the same
day of the week.
Solution: The pigeons are now the people in the group, and the pigeonholes are the
e = 4 people share the same day of the week.
days of the week. And so d 25
7

1.6.1

Exercises

Here are some exercises that apply the techniques presented in this chapter.
1. A store has t-shirts in 6 different styles and 4 different sizes. How many different kinds
of t-shirts does the store have?
2. In Example 2, we described the standard California license-plate number. How many
such numbers have
(a) no repeated digit?
(b) no repeated letter?
(c) no repeated symbol?
3. In how many ways can a ballot be validly marked if a person is to vote on three questions,
and at least one question must be answered (i.e. one or two questions may be skipped,
but not all three of them), if for question 1 there are four options to choose from, for
question 2 there are two options to choose from, and two more options to chose from for
question 3?
4. How many integers n, with 1 n 200, are not divisible by 2, 3, or 5?
5. Given five points in the plane, with integer coordinates, prove that there are two with
the property that the midpoint of the line segment joining them has integer coordinates.
6. Let S be a six-element subset of {1, 2, . . . , 14}. Show that there are two proper nonempty
subsets of S, say A and B such that the sum of the values of the elements of A is the
same as the sum of the values of the elements of B. Recall that A is a proper subset of
B if A B.
7. Use the principle of mathematical induction to generalize the product rule to arbitrarily
many tasks.
****************************************************************
Solutions to Exercises, Chapter 1 of Combinatorics Notes for MA1025
****************************************************************
1. A store has t-shirts in 6 different styles and 4 different sizes. How many different kinds
of t-shirts does the store have?
Solution: There are 6 + 6 + 6 + 6 = 6 4 = 24 (6 choices for each size).
2. In Example 2, we described the standard California license-plate number. How many
such numbers have
7

(a) no repeated digit?


(b) no repeated letter?
(c) no repeated symbol?
Solution:
(a) There are still 263 ways to choose the alpha characters, but now there are 9 choices
for the first digit, 9 for the second, 8 for the third, and 7 for the fourth. In all, there
are 9 263 9 8 7 such numbers.
(b) There are 9 103 ways to choose the digits, but now there are 26 25 24 ways to
choose the letters. In all, there are 9 26 25 24 103 such numbers.
(c) Combining the results from (a) and (b), there are 9 26 25 24 9 8 7 license
numbers with no repeated symbols.
3. In how many ways can a ballot be validly marked if a person is to vote on three questions,
and at least one question must be answered (i.e. one or two questions may be skipped,
but not all three of them), if for question 1 there are four options to choose from, for
question 2 there are two options to choose from, and two more options to chose from for
question 3?
Solution: There are 5 ways to answer question 1 (one of the 4 options, or skipping that
question). Then there are 3 ways to answer each of the questions 2 and 3. However we
counted the option that no question was answered wich is not a valid ballot. Thus the
are 5 3 3 1 = 53 different possible valid ballots.
4. How many integers n, with 1 n 200, are not divisible by 2, 3, or 5?
Solution: The number of integers n, with 1 n 200, that are divisible by at least
one of 2, 3, or 5 is

 
 
 
 
 
 

200
200
200
200
200
200
200
+
+

+
2
3
5
6
10
15
30
= 100 + 66 + 40 33 20 13 + 6 = 146,
so the number of integers in {1, 2, . . . , 200} divisible by none of them is 200 146 = 54.
5. Given five points in the plane, with integer coordinates, prove that there are two with
the property that the midpoint of the line segment joining them has integer coordinates.
Proof: Given two integer coordinate pairs (x1 , y1 ) and (x2 , y2 ), the midpoint of the line
1 y1 +y2
segment joining them has coordinates ( x1 +y
, 2 ), which is an integer pair only if both
2
x1 + x2 and y1 + y2 are even, which requires that the parity of x1 agrees with that of x2
and that the parity of y1 agrees with that of y2 . There are four parity patterns that an
ordered pair might have. These are (even,even), (odd,odd), (even,odd), and (odd,even).
Given five ordered pairs, two must share one of these patterns, but then the midpoint of
the line segment joining them has integer coordinates.
8

6. Let S be a six-element subset of {1, 2, . . . , 14}. Prove that there are two proper nonempty
subsets of S, say A and B such that the sum of the values of the elements of A is the
same as the sum of the values of the elements of B. Recall that A is a proper subset of
B if A B.
Proof: There are 26 2 = 62 nonempty proper subsets of S. The sum of the elements
of each such subset lies between 1 and 14 + 13 + 12 + 11 + 10 = 60. By the pigeonhole
principle, there must be a pair of subsets with identical sums.
7. Use the principle of mathematical induction to generalize the product rule to arbitrarily
many tasks.
Solution: The base case is the case of two tasks, which is covered by the basic product
rule. Assume that k tasks, where the ith task can be performed in ni ways, can be
Q
performed in ki=1 ni ways. Suppose we must perform k + 1 tasks, with ni the number
of ways in which the ith task can be performed. By the induction hypothesis, there
Q
to
are ki=1 ni ways to perform the first k tasks, and by hypothesis
Qthere are nk+1 ways
Qk+1
k
perform the (k +1)st task. By the basic product rule, there are
i=1 ni
i=1 ni nk+1 =
ways to perform all k + 1 tasks.
If you want additional exercises, here are some suggestions for exercises from the text by
Rosen. At the end of Section 5.1, you might work problems 3 15 (odds), 21, 26, 41, 43. In
Section 5.2, you might work problems 3, 5, 9, 13, 19, 29.
****************************************************************

1.7

Assessment

****************************************************************

Self-Quiz on Fundamentals of Counting


1. Buds Grill offers an earlybird dinner special, which includes one of four entrees, either
a soup (two kinds) or a salad (four choices), and a dessert (three choices). In how many
different ways can one order all three courses from the special menu?
2. How many functions are there from a 5-element set A to a 6-element set B? How many
are one-to-one?
3. How many subsets of {1, 2, . . . , 8} contain more than one element?
4. How many bitstrings of length eight either start with 01 or end with 01?
5. How many numbers must be selected from {1, 2, . . . , 10} to guarantee that there is a pair
whose sum is 11? How many, if the sum is to be 13?
9

6. At a party, there are n people for some n 2. Show that there must be two people at
the party who know precisely the same number of other people at the party.

Self-Quiz Solutions: Fundamentals of Counting


1. Buds Grill offers an earlybird dinner special, which includes one of four entrees, either
a soup (two kinds) or a salad (four choices), and a dessert (three choices). In how many
different ways can one order all three courses from the special menu?
Solution: A hypothetical diner can order an entree in four ways, one of six first courses,
and one of three desserts. By the product rule, there are 4 6 3 = 72 ways to order.
2. How many functions are there from a 5-element set A to a 6-element set B? How many
are one-to-one?
Solution: Let A = {a1 , a2 , . . . , a5 }. In the first case, there are 6 choices for the image
of each element ai A, so by the product rule there are 65 = 7776 such functions. If the
function must be one-to-one, there are six choices for the image of a1 , then five choices
for the image of a2 , etc. So there are 6 5 4 3 2 = 6! = 720 one-to-one functions from
A to B.
3. How many subsets of {1, 2, . . . , 8} contain more than one element?
Solution: All except the empty set and the eight singletons, so altogether 28 9 = 247
subsets contain more than one element.
4. How many bitstrings of length 8 either start with 01 or end with 01?
Solution: There are 26 that start with 01, 26 that end with 01, and 24 with both
properties, so the number in question is 2 26 24 = 112.
5. How many numbers must be selected from {1, 2, . . . , 10} to guarantee that there is a pair
whose sum is 11? How many, if the sum is to be 13?
Solution: There are five pairs ({1, 10}, {2, 9}, {3, 8}, {4, 7}, and {5, 6}) that add up
to 11, so we must choose six numbers to guarantee that we have both elements in one of
the five sets. There are four pairs ({3, 10}, {4, 9}, {5, 8}, and {6, 7}) that add up to 13,
and there are also the numbers 1 and 2, neither of which combines with another element
of the set to make 13. So we must choose seven numbers to guarantee that two of them
add up to 13.
6. At a party, there are n people for some n 2. Show that there must be two people at
the party who know precisely the same number of other people at the party.
Proof: The number of people known by each celebrant (these are the pigeons) is an
integer between 0 and n 1 (these are the labels on the pigeonholes). So it appears
that we have ten pigeonholes for ten pigeons. But now there are two cases. If any
10

individual knows nobody, then the pigeonhole labeled n 1 must be empty. Otherwise,
the pigeonhole labeled 0 must be empty. In either case, we have n pigeons but only n 1
pigeonholes. One of them must contain at least two pigeons.

11

You might also like