Data Structure Lect15
Data Structure Lect15
Lecture 15
Topics
Pigeon Hole Principal
Permutation
Example of Permutation
Combinations
Examples of Combination
Binomial Coefficients
Permutation
A permutation of a set of distinct objects is an ordered arrangement of these objects.
We also are interested in ordered arrangements of some of the elements of a set. An
ordered arrangement of r elements of a set is called an r-permutation.
then
P (n, r) = n! .
(n − r)!
Example 1
How many ways are there to select a first-prize winner, a second-prize winner,
and a third-prize winner from 5 different people who have entered a contest?
A B C D E
Solution:
Five persons A B C D E
Five positions ____,___, ____, ___, ____
5 4 3 2 1
5 x4 x 3x 2 x 1 = 120
nP = 5P5 = 5! = 5! = 120 = 120
r
(5-5)! 0! 1
IF n=r then
nP = n! = n! = n!
r
(n-r)! (n-n)! 1
Example 2
Suppose that there are eight runners in a race. The winner receives a gold
medal, the second place finisher receives a silver medal, and the third-place
finisher receives a bronze medal. How many different ways are there to award
these medals, if all possible outcomes of the race can occur and there are no
ties?
Solution:
The number of different ways to award the medals is the number of 3-
permutations of a set with eight elements. Hence, there are
P (8, 3) = 8 · 7 · 6 = 336
possible ways to award the medals.
Example 3
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.
Because these six objects can occur in any order, there are 6! = 720 permutations
of the letters ABCDEFGH in which ABC occurs as a block.
Example 4
In how many ways can we select three students from a group of eight students to
stand in line for a picture? In how many ways can we arrange all 8 of these students
in a line for a picture?
To arrange all eight students in a line for a picture, we select the first student in
eight ways, the second in seven ways, the third six ways, the fourth in five ways,
the fifth in four ways, sixth in three ways , seventh in 2 ways and eighth in 1 ways.
Consequently, there are
8 x 7 x 6 x 5 x 4 x 3 x 2 x 1 = 40320 ways to arrange all eight students in a line for a
picture.
Permutation