Chapter 6
Chapter 6
Chapter 6
With Question/Answer
Animations
Copyright © McGraw-Hill Education. All rights reserved. No reproduction or distribution without the prior written consent of McGraw-Hill Education.
Chapter Summary
The Basics of Counting
The Pigeonhole Principle
Permutations and Combinations
Binomial Coefficients and Identities
Generalized Permutations and Combinations
Generating Permutations and Combinations
(not yet included in overheads)
The Basics of Counting
Section 6.1
Section Summary
The Product Rule
The Sum Rule
The Subtraction Rule
The Division Rule
Examples, Examples, and Examples
Tree Diagrams
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.
there are 26 ∙ 26 ∙ 26 ∙ 10 ∙ 10 ∙ 10 =
Solution: By the product rule,
nm such functions.
office code, and a four-digit station code. There are some restrictions on the digits.
Let X denote a digit from 0 through 9.
Let N denote a digit from 2 through 9.
Let Y denote a digit that is 0 or 1.
In the old plan (in use in the 1960s) the format was NYX-NNX-XXX.
In the new plan, the format is NXX-NXX-XXX.
How many different telephone numbers are possible under the old plan and the
new plan?
By the product rule, there are 2|S| such bit strings, and
therefore 2|S| subsets.
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 DNA of bacteria has between 105 and 107 links (one of the
cytosine (C), guanine (G), or thymine (T).
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
representative.
The Sum 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,
26 + 26 ∙ 10 = 286
Solution: Use the product rule.
Counting Passwords
Combining the sum and product rule allows us to solve more complex problems.
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.
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:
Hostids consisting of all 0s and all 1s are not available in any network.
Counting Internet Addresses
Example: How many different IPv4 addresses are available for
computers on the internet?
Solution: Use both the sum and the product rule. Let x be the number
of available addresses, and let xA, xB, and xC denote the number of
addresses for the respective classes.
To find, xA: 27 − 1 = 127 netids. 224 − 2 = 16,777,214 hostids.
xA = 127∙ 16,777,214 = 2,130,706,178.
To find, xB: 214 = 16,384 netids. 216 − 2 = 16,534 hostids.
xB = 16,384 ∙ 16, 534 = 1,073,709,056.
To find, xC: 221 = 2,097,152 netids. 28 − 2 = 254 hostids.
xC = 2,097,152 ∙ 254 = 532,676,608.
Hence, the total number of available IPv4 addresses is
x = xA + xB + xC
= 2,130,706,178 + 1,073,709,056 + 532,676,608
= 3, 737,091,842.
Not Enough Today !!
The newer IPv6 protocol solves the
problem of too few addresses.
Basic Counting Principles: Subtraction Rule
Subtraction Rule: If a task can be done
either in one of n1 ways or in one of n2 ways,
00?
Solution: Use the subtraction rule.
= 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.
for every value y ∈ B there are exactly d values x ∈ A such that f(x) = y, then |B| =
In terms of functions: If f is a function from A to B, where both are finite sets, and
|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
Solution: Number the seats around the table from 1 to 4 proceeding clockwise.
and right neighbor?
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
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 Discrete Math” 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 book store
needs to stock to have one of each size and color available?
Solution: Draw the tree diagram.
where the inequality ⌈N/k⌉ < ⌈N/k⌉ + 1 has been used. This
is a contradiction because there are a total of n objects.
7! = 7 ∙ 6 ∙ 5 ∙ 4 ∙ 3 ∙ 2 ∙ 1 = 5040
ordered arbitrarily. Hence the orders are:
6! = 6 ∙ 5 ∙ 4 ∙ 3 ∙ 2 ∙ 1 = 720
Combinations
Definition: An r-combination of elements of a set is an
unordered selection of r elements from the set. Thus, an
r-combination is simply a subset of the set with r elements.
The number of r-combinations of a set with n distinct
elements is denoted by C(n, r). The notation is also
the six subsets {a, b}, {a, c}, {a, d}, {b, c}, {b, d}, and
{c, d}.
Combinations
Theorem 2: The number of r-combinations
of a set with n elements, where n ≥ r ≥ 0,
equals
and
manipulation. →
This result can be proved without using algebraic
Combinatorial Proofs
Definition 1: A combinatorial proof of an
identity is a proof that uses one of the
following methods.
A double counting proof uses counting
arguments to prove that both sides of an
identity count the same objects, but in different
ways.
A bijective proof shows that there is a
bijection between the sets of objects counted
by the two sides of the identity.
Combinatorial Proofs
Here are two combinatorial proofs that
C(n, r) = C(n, n − r)
when r and n are nonnegative integers with r < n:
Bijective Proof: Suppose that S is a set with n elements. The
function that maps a subset A of S to is a bijection
Terms of the form x3, x2y, x y2, y3 arise. The question is what are the coefficients?
from each of the three sums.
To obtain x3 , an x must be chosen from each of the sums. There is only one way to do
this. So, the coefficient of x3 is 1.
To obtain x2y, an x must be chosen from two of the sums and a y from the other. There
are ways to do this and so the coefficient of x2y is 3.
To obtain xy2, an x must be chosen from of the sums and a y from the other two . There
are ways to do this and so the coefficient of xy2 is 3.
To obtain y3 , a y must be chosen from each of the sums. There is only one way to do this.
So, the coefficient of y3 is 1.
We have used a counting argument to show that (x + y)3 = x3 + 3x2y + 3x y2 + y3 .
Next we present the binomial theorem gives the coefficients of the terms in the
expansion of (x + y)n .
Binomial Theorem
Binomial Theorem: Let x and y be
variables, and n a nonnegative integer. Then:
Pascal’s Identity
Pascal’s Identity: If n and k are integers with n ≥ k ≥ 0, then
There are
subsets of k elements that contain a, since there are
subsets of k − 1 elements of S,
Hence, 19 for an
See Exercise
algebraic
proof.
Pascal’s Triangle
The nth row in
the triangle
consists of the
binomial
coefficients
k = 0,1,….,n.
,
elements.
Combinations with Repetition
Example: How many ways are there to
select five bills from a box containing at least
five of each of the following denominations:
$1, $2, $5, $10, $20, $50, and $100?
Solution: Place the selected bills in the
appropriate position of a cash box illustrated
below:
→
continued
Combinations with Repetition
Some possible ways of
placing the five bills:
solutions.
Combinations with Repetition
Example: Suppose that a cookie shop has
four different kinds of cookies. How many
different ways can six cookies be chosen?
n − n1 positions.
The n1 objects of type one can be placed in the n positions in C(n, n1 ) ways, leaving
− n1 positions in
C(n − n1, n2 ) ways, leaving n − n1 − n2 positions.
Then the n2 objects of type two can be placed in the n