Combinatorics: Rosen 6 Ed., 5.1-5.3, 5.5
Combinatorics: Rosen 6 Ed., 5.1-5.3, 5.5
1
Combinatorics
• Count the number of ways to put things
together into various combinations.
e.g. If a password is 6-8 letters and/or digits,
how many passwords can there be?
• Two main rules:
– Sum rule
– Product rule
2
Sum Rule
• Let us consider two tasks:
– m is the number of ways to do task 1
– n is the number of ways to do task 2
– Tasks are independent of each other, i.e.,
• Performing task 1 does not accomplish task 2 and
vice versa.
• Sum rule: the number of ways that “either
task 1 or task 2 can be done, but not both”,
is m+n.
• Generalizes to multiple tasks ...
3
Example
• A student can choose a computer project from one of three
lists. The three lists contain 23, 15, and 19 possible
projects respectively. How many possible projects are
there to choose from?
4
Set Theoretic Version
• If A is the set of ways to do task 1, and B
the set of ways to do task 2, and if A and B
are disjoint, then:
5
Product Rule
• Let us consider two tasks:
– m is the number of ways to do task 1
– n is the number of ways to do task 2
– Tasks are independent of each other, i.e.,
• Performing task 1does not accomplish task 2 and
vice versa.
• Product rule: the number of ways that
“both tasks 1 and 2 can be done” in mn.
• Generalizes to multiple tasks ...
6
Example
• The chairs of an auditorium are to be labeled with a letter
and a positive integer not to exceed 100. What is the
largest number of chairs that can be labeled differently?
7
Set Theoretic Version
• If A is the set of ways to do task 1, and B
the set of ways to do task 2, and if A and B
are disjoint, then:
• The ways to do both task 1 and 2 can be
represented as AB, and |AB|=|A|·|B|
8
More Examples
• How many different bit strings are there of
length seven?
9
More Examples
• Suppose that either a member of the CS faculty or a
student who is a CS major can be on a university
committee. How many different choices are there if there
are 37 CS faculty and 83 CS majors ?
10
More Examples
• How many different license plates are
available if each plate contains a sequence
of three letters followed by three digits?
11
Example Using Both Rules
• 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?
12
Permutations
• A permutation of a set S of objects is an ordered
arrangement of the elements of S where each
element appears only once:
e.g., 1 2 3, 2 1 3, 3 1 2
• An ordered arrangement of r distinct elements of S
is called an r-permutation.
• The number of r-permutations of a set S with n=|S|
elements is
P(n,r) = n(n−1)…(n−r+1) = n!/(n−r)!
13
Example
• How many ways are there to select a third-
prize winner from 100 different people who
have entered a contest?
14
More Examples
• A terrorist has planted an armed nuclear bomb in
your city, and it is your job to disable it by cutting
wires to the trigger device.
• There are 10 wires to the device.
• If you cut exactly the right three wires, in exactly
the right order, you will disable the bomb,
otherwise it will explode!
• If the wires all look the same, what are your
chances of survival?
P(10,3) = 10·9·8 = 720,
so there is a 1 in 720 chance
that you’ll survive! 15
More Examples
• How many permutations of the letters
ABCDEFG contain the string ABC?
16
Combinations
• The number of ways of choosing r elements
from S (order does not matter).
S={1,2,3}
e.g., 1 2 , 1 3, 2 3
• The number of r-combinations C(n,r) of a set
with n=|S| elements is
n n!
C (n, r )
r r !(n r )!
17
Combinations vs Permutations
• Essentially unordered permutations …
P ( n, r ) C ( n, r ) P ( r , r )
n P(n, r ) n! /(n r )! n!
C (n, r )
r P(r , r ) r! r!(n r )!
18
Combination Example
• How many distinct 7-card hands can be
drawn from a standard 52-card deck?
– The order of cards in a hand doesn’t matter.
• Answer C(52,7) = P(52,7)/P(7,7)
= 52·51·50·49·48·47·46 / 7·6·5·4·3·2·1
17 10 7 8
2
52·17·10·7·47·46 = 133,784,560
19
More Examples
• How many ways are there to select a committee to develop
a discrete mathematics course if the committee is to
consist of 3 faculty members from the Math department
and 4 from the CS department, if there are 9 faculty
members from Math and 11 from CS?
20
Example
• How many strings of length eight either
start with a 1 bit or end with the two bit
string 00?
21
Generalized
Permutations and Combinations
• How to solve counting problems where
elements may be used more than once?
• How to solve counting problems in which
some elements are not distinguishable?
• How to solve problems involving counting
the ways we to place distinguishable
elements in distinguishable boxes?
22
Permutations with
non-distinguishable objects
• The number of different permutations of n
objects, where there are n1 non-distinguishable
objects of type 1, n2 non-distinguishable objects
of type 2, …, and nk non-distinguishable objects
of type k, is
n!
n1 !n2 !...nk !
i.e., C(n, n1)C(n- n1, n)…C(n-
2 n-1 n2-…- nk 1, nk)
n1 n2 ... nk n
23
Permutations with Repetition
• The number of r-permutations of a set of n objects
with repetition allowed is n r
• Example: How many strings of length n can be
formed from the English alphabet?
24
Permutations with
non-distinguishable objects
• Example: How many different strings can be
made by reordering the letters of the word
SUCCESS
25
Thank You
26