Combinations and Permutations
Combinations and Permutations
Permutations
"The combination to the safe is 472". Now we do care about the order.
"724" won't work, nor will "247". It has to be exactly 4-7-2.
Permutations
There are basically two types of permutation:
When a thing has n different types ... we have n choices each time!
n×n×n
(n multiplied 3 times)
n × n × ... (r times)
(In other words, there are n possibilities for the first choice, THEN there
are n possibilites for the second choice, and so on, multplying each time.)
nr
where n is the number of things to choose from,
and we choose r of them,
repetition is allowed,
and order matters.
In this case, we have to reduce the number of available choices each time.
So, our first choice has 16 possibilites, and our next choice has 15 possibilities,
then 14, 13, 12, 11, ... etc. And the total permutations are:
16 × 15 × 14 × 13 × ... = 20,922,789,888,000
But maybe we don't want to choose them all, just 3 of them, and that is then:
16 × 15 × 14 = 3,360
In other words, there are 3,360 different ways that 3 pool balls could be
arranged out of 16 balls.
Without repetition our choices get reduced each time.
But how do we write that mathematically? Answer: we use the " factorial
function "
4! = 4 × 3 × 2 × 1 = 24
7! = 7 × 6 × 5 × 4 × 3 × 2 × 1 = 5,040
1! = 1
Note: it is generally agreed that 0! = 1. It may seem funny that multiplying
no numbers together gets us 1, but it helps simplify a lot of equations.
So, when we want to select all of the billiard balls the permutations are:
16! = 20,922,789,888,000
But when we want to select just 3 we don't want to multiply after 14. How do
we do that? There is a neat trick: we divide by 13!
16 × 15 × 14 × 13 × 12 ...13 × 12 ... = 16 × 15 × 14
That was neat. The 13 × 12 × ... etc gets "cancelled out", leaving only 16 ×
15 × 14.
n!(n − r)!
Notation
Instead of writing the whole formula, people use different notations such as
these:
Example: P(10,2) = 90
Combinations
There are also two types of combinations (remember the order does not matter
now):
Actually, these are the hardest to explain, so we will come back to this later.
Going back to our pool ball example, let's say we just want to know which 3
pool balls are chosen, not the order.
But many of those are the same to us now, because we don't care what order!
For example, let us say balls 1, 2 and 3 are chosen. These are the possibilites:
In fact there is an easy way to work out how many ways "1 2 3" could be placed
in order, and we have already talked about it. The answer is:
3! = 3 × 2 × 1 = 6
That formula is so important it is often just written in big parentheses like this:
where n is the number of things to choose from,
and we choose r of them,
no repetition,
order doesn't matter.
It is often called "n choose r" (such as "16 choose 3")
Notation
n!r!(n − r)!
= 20,922,789,888,0006 × 6,227,020,800
= 560
Pascal's Triangle
We can also use Pascal's Triangle to find the values. Go down to row "n" (the
top row is 0), and then along "r" places and the value there is our answer. Here
is an extract showing row 16:
1 14 91 364 ...
1 15 105 455 1365 ...
1 16 120 560 1820 4368 ...
Let us say there are five flavors of icecream: banana, chocolate, lemon,
strawberry and vanilla.
We can have three scoops. How many variations will there be?
Let's use letters for the flavors: {b, c, l, s, v}. Example selections include
(And just to be clear: There are n=5 things to choose from, and we
choose r=3 of them.
Order does not matter, and we can repeat!)
Now, I can't describe directly to you how to calculate this, but I can show you
a special technique that lets you work it out.
Think about the ice cream being in boxes, we could say "move past
the first box, then take 3 scoops, then move along 3 more boxes to
the end" and we will have 3 scoops of chocolate!
So it is like we are ordering a robot to get our ice cream, but it doesn't change
anything, we still get what we want.
Notice that there are always 3 circles (3 scoops of ice cream) and 4 arrows (we
need to move 4 times to go from the 1st to 5th container).
This is like saying "we have r + (n−1) pool balls and want to choose r of
them". In other words it is now like the pool balls question, but with slightly
changed numbers. And we can write it like this:
where n is the number of things to choose from,
and we choose r of them
repetition allowed,
order doesn't matter.
Interestingly, we can look at the arrows instead of the circles, and say "we
have r + (n−1) positions and want to choose (n−1) of them to have arrows",
and the answer is the same:
(3+5−1)! 7! 5040
= = = 35
3!(5−1)! 3!×4! 6×24
In Conclusion
Phew, that was a lot to absorb, so maybe you could read it again to be sure!
But knowing how these formulas work is only half the battle. Figuring out how
to interpret a real world situation can be quite hard.
But at least now you know how to calculate all 4 variations of "Order does/does
not matter" and "Repeats are/are not allowed".
Permutation
A permutation, also called an "arrangement number" or "order," is a rearrangement of the elements of an ordered
list into a one-to-one correspondence with itself. The number of permutations on a set of elements is given
by ( factorial; Uspensky 1937, p. 18). For example, there are permutations of ,
namely and , and permutations of , namely , ,
, , , and . The permutations of a list can be found in the Wolfram Language using the
command Permutations[list]. A list of length can be tested to see if it is a permutation of 1, ..., in the Wolfram
Language using the command PermutationListQ[list].
Sedgewick (1977) summarizes a number of algorithms for generating permutations, and identifies the minimum
change permutation algorithm of Heap (1963) to be generally the fastest (Skiena 1990, p. 10). Another method of
enumerating permutations was given by Johnson (1963; Séroul 2000, pp. 213-218).
The number of ways of obtaining an ordered subset of elements from a set of elements is given by
(1)
(Uspensky 1937, p. 18), where is a factorial. For example, there are 2-subsets of ,
namely , , , , , , , , , , , and .
The unordered subsets containing elements are known as the k-subsets of a given set.
A representation of a permutation as a product of permutation cycles is unique (up to the ordering of the cycles). An
example of a cyclic decomposition is the permutation of . This is denoted ,
corresponding to the disjoint permutation cycles (2) and (143). There is a great deal of freedom in picking the
representation of a cyclic decomposition since (1) the cycles are disjoint and can therefore be specified in any order,
and (2) any rotation of a given cycle specifies the same cycle (Skiena 1990, p. 20). Therefore, (431)(2), (314)(2),
(143)(2), (2)(431), (2)(314), and (2)(143) all describe the same permutation.
Another notation that explicitly identifies the positions occupied by elements before and after application of a
permutation on elements uses a matrix, where the first row is and the second row is the new
arrangement. For example, the permutation which switches elements 1 and 2 and fixes 3 would be written as
(2)
The number of wrong permutations of objects is where is the nearest integer function. A permutation
of ordered objects in which no object is in its natural place is called a derangement (or sometimes, a complete
permutation) and the number of such permutations is given by the subfactorial .
Using
(3)
with gives
(4)
The set of all permutations of a set of elements 1, ..., can be obtained using the following recursive procedure
(5)
(6)
Consider permutations in which no pair of consecutive elements (i.e., rising or falling successions) occur. For ,
2, ... elements, the numbers of such permutations are 1, 0, 0, 2, 14, 90, 646, 5242, 47622, ... (OEIS A002464).
Let the set of integers 1, 2, ..., be permuted and the resulting sequence be divided into increasing runs. Denote the
average length of the th run as approaches infinity, . The first few values are summarized in the following
table, where e is the base of the natural logarithm (Le Lionnais 1983, pp. 41-42; Knuth 1998).
OEIS approximate
1.7182818..
1 A091131
.
2 A091132 1.9524...
3 A091133 1.9957...
How To Tell the Difference
The difference between combinations and permutations is
ordering. With permutations we care about the order of
the elements, whereas with combinations we don’t.
For example, say your locker “combo” is 5432. If you enter 4325
into your locker it won’t open because it is a different ordering
(aka permutation).
Now there are 3 options left for the second blank because you’ve
already used one of the numbers in the first blank. Place a “3” in
the next space.
For the third position, you have two numbers left.
And there is one number left for the last position, so place a “1”
there.
The Multiplication Principle
Using the Multiplication Principle of combinatorics, we know that
if there are x ways of doing one thing and y ways of doing another,
then the total number of ways of doing both things is x•y. That
means we need to multiply to find the total permutations.
Choosing a Subset
Let’s up the ante with a more challenging problem:
Assuming no one else is drawing cards from the deck, there are 52
cards available on the first draw, so place “52” in the first blank.
Once you choose a card, there will be one less card available on the
next draw. So the second blank will have 51 options. The next draw
will have two less cards in the deck, so there are now 50 options,
and so on.
We’d like to divide out all the integers except those from 48 to 52.
To do this divide by 47! since it’s the product of the integers from
47 to 1.
Make sure to divide by 5! to get rid of the extra permutations:
There we go!
Now here’s the cool part → we have actually derived the formula
for combinations.
Combinations Formula
If we have n objects and we want to choose k of them, we can find
the total number of combinations by using the following formula:
read: “n choose k”
Permutations Formula
The formula for permutations is similar to the combinations
formula, except we needn’t divide out the permutations, so we can
remove k! from the denominator:
read: n permutate k elements