10/17/2016 1
Permutations and Combinations
Rosen, Chapter 5.3
Motivating question
In a family of 3, how many ways can we
Permutations and Combinations Rosen, Chapter 5.3 Motivating - - PDF document
10/17/2016 Permutations and Combinations Rosen, Chapter 5.3 Motivating question In a family of 3, how many ways can we arrange the members of the family in a line for a photograph? 1 10/17/2016 Permutations A permutation of a set of
In a family of 3, how many ways can we
A permutation of a set of distinct objects is an
Example: (1, 3, 2, 4) is a permutation of the
How many permutations of n objects are
How many permutations of n objects are
Using the product rule:
Anagram: a word, phrase, or name formed by
The anagram server: http://wordsmith.org/anagram/
How many ways can we arrange 4 students
How many ways can we arrange 4 students
How many ways can we select 3 students
How many ways can we select 3 students
permutation – a permutation of a set of
r-permutation – a ordered arrangement of r
You invite 4 people for a dinner party. How
A) 6 (3!) B) 24 (4!) C) 120 (5!) D) 16 (n2) E) 32 (2n2)
You invite 4 people for a dinner party. How
A) 6 (3!) B) 24 (4!) C) 120 (5!) D) 16 (n2) E) 32 (2n2)
In how many ways can a photographer at a
In how many ways can a photographer at a
6! = 720
In how many ways can a photographer at a
A.
B.
C.
D.
E.
In how many ways can a photographer at a
A.
B.
C.
D.
E.
In how many ways can a photographer at a
In how many ways can a photographer at a
A.
B.
C.
D.
E.
In how many ways can a photographer at a
A.
B.
C.
D.
E.
In how many ways can a photographer at a
6! possible ways for 6 2*5! - possible ways the bride is next to the
In how many ways can a photographer at a
In how many ways can a photographer at a
5! + (4 · 4!) + (3 · 4!) + (2 · 4!) + (1 · 4!) =
The first position to fill is the position of the
5! + (4 · 4!) + (3 · 4!) + (2 · 4!) + (1 · 4!) =
Count the number of ways to arrange n men
Count the number of ways to arrange n men
Count the number of ways to arrange n men
An optimal TSP tour through Germany’s 15 largest cities
Go through all permutations of cities, and
Need a method for generating all
Note: how many solutions to a TSP problem
Let's design a recursive algorithm for
Let's design a recursive algorithm for
Starting point: decide which element to put first what needs to be done next? what is the base case?
Is our algorithm for TSP that considers all
An ordered arrangement of r elements of a set:
Example: List the 2-permutations of {a,b,c}.
The number of r-permutations of a set of n elements: then
How many ways are there to select a first
How many ways are there to select a first
How many permutations of the letters
How many permutations of the letters
How many permutations of the letters
Suppose there are 8 runners in a race. The
Suppose there are 8 runners in a race. The
How many poker hands (five cards) can be
How is this different than r-permutations?
An r-combination of a set is a subset of size r The number of r-combinations out of a set
{1,3,4} is a 3-combination of {1,2,3,4} How many 2-combinations of {a,b,c,d}?
How many r-combinations?
C(n,r) satisfies:
We can see that easily without using the formula
Two ordered selections are the same if
the elements chosen are the same; the elements chosen are in the same order.
Ordered selections: r-permutations. Two unordered selections are the same if
the elements chosen are the same.
(regardless of the order in which the elements are chosen)
Unordered selections: r-combinations.
44
Suppose we want to compute P(n,r) . Constructing an r-permutation from a set of n elements
Step 1 can be done in C(n,r) different ways. Step 2 can be done in r! different ways. Based on the multiplication rule, P(n,r) = C(n,r) ∙ r! Thus
45
How many poker hands (five cards) can be
How many poker hands (five cards) can be
There are 52! / 47! Permutations so
Since order doesn’t matter, there are 5!
The faculty in biology and computer science want to
A.
B.
C.
D.
E.
The faculty in biology and computer science want to
A.
B.
C.
D.
E.
There are C(20,2) combinations of CS There are C(30,2) combinations of Biology Using the product rule the total combinations
A coin is flipped 10 times, producing
A coin is flipped 10 times, producing
A coin is flipped 10 times, producing
A coin is flipped 10 times, producing
A coin is flipped 10 times, producing
A coin is flipped 10 times, producing
A coin is flipped 10 times, producing
1 way for 0 tails 10 ways for 1 tail 10!/2!*8! = 90/2 = 45 ways for 2 tails 10!/3!*7! = 720/6 = 120 ways for 3 tails
A coin is flipped 10 times, producing
A coin is flipped 10 times, producing
While commanding the Enterprise, Spock has
How can we do this?
consider the nth object
C(k, k) = 1
C(n, 0) = 1
This is an example of a recurrence relation, which is a
Apply the multiplication rule if
The elements to be counted can be obtained through
Each step is performed in a fixed number of ways
Apply the addition rule if
The set of elements to be counted can be broken up
Apply the inclusion/exclusion rule if
It is simple to over-count and then to subtract
67
Make sure that
When using the addition rule:
68