Permutations HMM HMM
Permutations HMM HMM
Spring 2017
What is Combinatorics
Combinatorics, the study of arrangements of objects, is an
important part of discrete mathematics. This subject was
studied as long ago as the seventeenth century, when
combinatorial questions arose in the study of gambling games
Enumeration is the counting of objects with certain properties
Combinatorics is used in
Discrete probability: What is the probability to guess a
6-symbols password in the first attempt?
Analysis of algorithms: Why a comparison sort algorithm
cannot be more efficient than O(n log n)?
Probabilistic proofs: Show that the local search algorithm with
high probability does not find a good solution to a problem
Basic Counting Principles: The Sum Rule
If a first task can be performed in m ways, while a second task
can be performed in n ways, and the two tasks cannot be
performed simultaneously, then performing either task can be
accomplished in any one of m + n ways
Example: Suppose that either a member of the mathematics
faculty or a student who is a mathematics major is chosen as
a representative to a university committee. How many
different choices are there for this representative if there are
37 members of the mathematics faculty and 83 mathematics
majors
Solution: There are 37 ways to choose a faculty member, and
there are 83 ways to choose a student.
By the rule of sum there are 37 + 83 = 120 possible choices
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
Example: How many bit strings of length seven are there?
Solution: Since each of the seven bits is either a 0 or a 1, the
answer is 27 = 128
Example: A new company with just two employees, Sanchez
and Patel, rents a floor of a building with 12 offices. How
many ways are there to assign different offices to these two
employees?
Solution: The procedure of assigning offices consists of
assigning an office to Sanchez, which can be done in 12 ways,
then assigning an office to Patel different from the office
assigned to Sanchez, which can be done in 11 ways
By the rule of product, there are 12 × 11 = 132 ways to assign
offices
Basic Counting Principles: The Product Rule
Example: The chairs of an auditorium are to be labeled with a
letter and a positive integer not exceeding 100. What is the
largest number of chairs that can be labeled differently?
Solution: The procedure of labeling a chair consists of two
tasks, namely, assigning one of the 26 letters and then
assigning one of the 100 possible integers to the seat. By the
rule of product, there are 26 × 100 = 2600 different labels
Example: How many functions are there from a set with m
elements to a set with n elements?
Solution: A function corresponds to a choice of one of the n
elements in the codomain for each of the m elements of the
domain.
By the rule of product, there are n × n × · · · × n = nm
functions
Permutations
Example: In how many ways can we select 3 students from a
group of 5 students to stand in a line for a picture?
Solution: First, note that the order in which we select
students matters. There are 5 ways to select the first student.
Once the first one is selected we are left with 4 ways to select
the second student. After selecting the first two students
there are 3 ways to select the third one
By the rule of product, there are 5 × 4 × 3 = 60 ways to select
students
Permutations
Given a collection of n distinct objects, any (linear)
arrangement of these objects is called a permutation of the
collection
A permutation of size r (0 ≤ r ≤ n) is any (linear)
arrangement of r distinct objects from the collection
The Number of Permutations
The number P(n, r ) of permutations of size r from a
collection of n objects can be found as follows:
We choose r elements out of n and the order matters
There are n ways to choose the first element
There are n − 1 ways to choose the second element
·
·
·
There are n − r + 1 ways to choose the r th element
By the rule of product,
P(n, r ) = n × (n − 1) × (n − 2) × · · · × (n − r + 1)
The Number of Permutations
Recall that n! = 1 × 2 × 3 × · · · × (n − 1) × n
n!
Therefore P(n, r ) = (n−r )!
n!
P(n, n) = (n−n)! = n!
The Number of Permutations
Example: How many permutations of the letters ABCDEFGH
contain the string ABC ?
Solution: Because the letters ABC must occur as a block, we
can find the answer by finding the number of permutations of
six objects, namely, the block ABC and the individual letters
D, E , F , G , and H. Since these six objects can occur in any
order, there are
P(6, 6) = 6! = 720
permutations of the letters ABCDEFGH in which ABC occurs
as a block
Permutations with Repetitions
How many different 4-letter words (not necessarily
meaningful) can be built permuting the letters of the word
COOL?
If all letters were distinct then the answer would be the
number of all permutations of a 4-element set. However, in
words we build we do not distinguish two O
So, words O1 CLO2 and O2 CLO1 are equal. For each of the
words we are interested in, there are two words in which the
two O’s are distinguished
4!
Therefore the answer is 2 = 12
Permutations with Repetitions
Theorem: If there are n objects with n1 indistinguishable
objects of a first type, n2 indistinguishable objects of a second
type, . . . , and nr indistinguishable objects of a type r , where
n1 + n2 + · · · + nr = n, then there are
n!
P(n1 , n2 , . . . , nr ) =
n1 !n2 ! . . . nr !
(linear) arrangements of the given n objects
Each arrangement of this type is called a permutation with
repetitions
Permutations with Repetitions
Proof: Let us denote objects by capital letters and add
subscripts to indistinguishable objects so that they become
distinct
Then
A1 , A2 , . . . , An1 are the objects of the first type
B1 , B2 , . . . , Bn2 are the objects of the second type
·
·
In how many ways can we construct a permutation of the n
distinct objects?
Clearly there are P(n, n) = n! ways to do so
Now we split this process into stages:
first choose a permutation of indistinguishable objects
then select a permutation of A’s, of B’s etc
Permutations with Repetitions
Proof (continued):
Consider an arrangement of the n objects with r types of
indistinguishable objects (n1 objects of type 1, etc.):
A...B ...B ...A...A...B ...
If we distinguish between the n1 objects of type 1, then we get
the arrangement below:
A1 . . . B . . . B . . . A2 . . . An1 . . . B . . . (we can get n1 ! such
arrangements that distinguish between the type 1 objects)
If we distinguish between the n2 objects of type 2, then we get
the arrangement below:
A1 . . . B1 . . . B2 . . . A2 . . . An1 . . . Bn2 . . . (we can get n2 ! such
arrangements that distinguish between the type 2 objects)
·
·
If we distinguish between all types of objects, we get n!
arrangements in total.
Therefore, n! = P(n1 , n2 , . . . , nr )n1 !n2 ! . . . nr !
Permutations with Repetitions
Example: Determine the number of (staircase) paths in the
xy -plane from (0, 0) to (6, 4), where each such path is made
up of individual steps going one unit to the right (R) or one
unit upward (U)
Solution:
Homework for practice (not graded)
Exercises from the Book:
Section 6.3: Exercises 2, 4, 6, 8, 10, 12