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

0% found this document useful (0 votes)
21 views18 pages

Chap06 Counting

counting lesson

Uploaded by

heo11296
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)
21 views18 pages

Chap06 Counting

counting lesson

Uploaded by

heo11296
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/ 18

Chapter 6

Counting
6.1 The Basics of Counting
6.3 Permutations and
Combinations

P. 335
6.1 The Basics of Counting

• Basic Counting Principles


– The product rule: Suppose that a procedure can be
broken down into a sequence of two tasks. If there are
n1 ways to do the first task and for each of these ways,
there are n2 ways to do the second task, then there
are n1n2 ways to do the procedure
• Ex.1-10
– The sum rule: If a task can be done either in one of n1
ways or in one of n2 ways, where none of the set of n1
ways is the same as any of the set of n2 ways, then
there are n1+n2 ways to do the task
• Ex. 11-13
• The product rule: 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 in each set.
– |A1 A2  … Am|= |A1||A2| …|Am|
• The sum rule: If A1,A2 ,…,Am are disjoint finite
sets, then the number of elements in the union of
these sets is the sum of the number of elements
in each set.
– |A1 A2  …  Am|= |A1|+|A2|+ …+|Am|
Example
Suppose a password consists of:
• 3 digits. How many different passwords are
possible with 3 digits?
– 3 parts to password Pick p1 AND p2 AND p3
– n = n1 * n2 * n3 = 10 * 10 * 10 = 103 = 1,000
• 1 digit followed by 1 letter
– 10 * 26
• 3 digits followed by 2 letters
– 5 independent parts p1 AND p2 AND p3 AND p4 AND p5
– n = n1 * n2 * n3 * n4 * n5 = 10 * 10 * 10 * 26 * 26
= 103 * 262 = 676,000
Examples
• How many strings of 3 digits do not
contain the same digit twice?
– 10 ways to pick first digit.
– 9 ways to pick second digit.
– 8 ways to pick third digit.
– 10*9*8 by Product Rule
• How many strings of 3 digits begin with
an odd digit?
– 5 ways to pick first digit. {1, 3, 5, 7, 9}
– 10 ways to pick second digit. 10 ways to pick
third digit. 5*10*10 by Product Rule
FIGURE 1 (5.1)

FIGURE 1 Internet Addresses (IPv4).

P. 341
• How many Class A addresses are there?
– 27-1 * 224 -2 = 2,130,706,178
– Pick netid AND hostid
The Inclusion-Exclusion Principle

• Suppose a task can be done in n1 or n2


ways, but some of the set of n1 ways are
the same as some of the n2 ways, we have
to subtract the number of ways to do the
task that is both among the set of n1 ways
and the set of n2 ways
– The subtraction principle
– |A1 A2 |= |A1|+|A2|- |A1 A2 |
– Ex. 17-18
Example
• our favorite restaurant has a dinner menu.
• You only want one item. How many
different items can you choose from?
Appetizer OR Entree Appetizer Entree
1 Calamari Hamburger
2 Sushi Steak
3 Buffalo wings Chicken
4 Cheeze Wiz Fried Fish
5 Samosa Burrito
6 Burrito
• | Appetizer ∪ Entree | =
• |Appetizer| + |Entree| - |Appetizer ∩
Entree| = 6 + 5 - 1 = 10
6.3 Permutations and Combinations

• Permutations
– A permutation of a set of distinct objects is an
ordered arrangement of these objects
– r-permutation: an ordered arrangement of r
elements of a set
– Ex.1
– Ex.2
– P(n,r): the number of r-permutations of a set
with n elements
• Theorem 1: If n is a positive integer and r
is an integer with 1<=r<=n, then there are
P(n,r)=n(n-1)(n-2)…(n-r+1) r-permutations
of a set with n distinct elements.
– P(n,0)=1
– P(n,n)=n!
• Corollary 1: If n and r are integers with
0<=r<=n, then P(n,r)=n!/(n-r)!
– Ex. 4-7
Example

• You need to fly to 5 cities in any order,


how many possible air tickets do you need
to consider?
– Pick 1 of 5 cities to visit first. 5
– Pick 1 of 4 remaining to visit second. *4
– Pick 1 of 3 remaining to visit third. *3
– Pick 1 of 2 remaining to visit fourth. *2
– Pick 1 of 1 remaining to visit last. *1
– Total 5*4*3*2*1 = 5! = 120
Example
• S = {a, b, c}, (a, b) ≠ (b, a) it is a different 2-
permutation of S. How many different ways
are there to order {a, b, c} as a 2-tuple?
• Often stated as "What are all the possible ways
to take 3 things, 2 at a time?"
– 2 picks Ways to pick
– Pick 1 of 3 from {a, b, c}. 3
– Pick 1 from remaining 2. *2
– 3*2 = 6
– {(a, b), (a, c), (b, a), (b, c), (c, a), (c, b)}
• Combinations
– Finding the number of subsets of a particular
size
– r-combination: an unordered selection of r
elements from the set
– Ex.8-9
– C(n,r): the number of r-combinations of a set
with n elements
n
• Also denoted by   , and is called a binomial
coefficient r
Example

• S = {a, b, c}
– (a, b) ≠ (b, a), a different 2-permutation of S
– {a, b} = {b, a}, are the same 2-combinations of S
• How many 2-combinations (subsets of 2
elements) of S?
– n=3, r=2
– C(n, r) = n! / r!(n-r)!
– C(3,2) = 3! / 2!(3-2)! = 6 / 2 = 3
• Theorem 2: The number of r-combinations of a
set with n elements, where n is a nonnegative
integer and r is an integer with 0<=r<=n, equals
C(n,r)=n!/(r!(n-r)!)
– Proof
– C(n,r)=n(n-1)…(n-r+1)/r!
• Corollary 2: Let n and r be nonnegative integers
with r<=n. Then C(n,r)=C(n,n-r).
– Proof
Example
• How many license plates of 3 letters followed
by 3 digits? 263*103
• How many license plates of 3 letters followed
by 3 digits contain exactly two matching
digits?
– Number where digits occur only once: 10 ways to
pick first digit, 9 ways to pick second, 8 ways to
pick third: 10*9*8 = 720
– Number where all digits the same: 10 digits so 10
ways, 000, 111, etc.
– Total without two matching digits: 270 = 1000 -
720 – 10 = 263*270

You might also like