30-Permutations VU
Lecture No.30 Permutations
FACTORIAL
K-SAMPLE
K-PERMUTATION
FACTORIAL OF A POSITIVE INTEGER:
For each positive integer n, its factorial is defined to be the product of all the integers
from 1 to n and is denoted n!. Thus n! = n(n - 1) (n - 2) … 3⋅2 ⋅1
In addition, we define
0! = 1
REMARK:
n! can be recursively defined as
Base: 0! = 1
Recursion n! = n (n - 1)! for each positive integer n.
EXERCISE:
Compute each of the following
7!
(i) (ii) (−2)!
5!
(n+1)! (n −1)!
(iii) (iv)
n! (n+1)!
SOLUTION:
7 ! 7 ⋅ 6 ⋅ 5!
(i ) = = 7 ⋅ 6 = 42
5! 5!
( ii ) ( − 2 )! is not defined
( n + 1) ! ( n + 1) n !
( iii ) = = n +1
n! n!
( n − 1) ! ( n − 1) ! 1 1
( iv ) = = =
( n + 1) ! ( n + 1) ⋅ n ⋅ ( n − 1) ! ( n + 1) n n 2 + n
EXERCISE:
Write in terms of factorials.
(i) 25⋅24 ⋅23 ⋅22 (ii) n(n-1)(n-2) … (n - r + 1)
n(n − 1)( n − 2) ⋅⋅⋅ ( n − r + 1)
(iii)
1 ⋅ 2 ⋅ 3 ⋅⋅⋅ ( r − 1) ⋅ r
SOLUTION:
25 ⋅ 24 ⋅ 23 ⋅ 22 ⋅ 21! 25!
(i ) 25 ⋅ 24 ⋅ 23 ⋅ 22 = =
21! 21!
n(n − 1)(n − 2) ⋅⋅⋅ (n − r + 1)(n − r)!
(ii ) n(n − 1)(n − 2) ⋅⋅⋅ (n − r + 1) =
(n − r)!
n!
=
(n − r)!
218
© Copyright Virtual University of Pakistan
30-Permutations VU
n (n − 1)( n − 2) ⋅⋅⋅ ( n − r + 1) n( n − 1)(n − 2) ⋅⋅⋅ ( n − r + 1)
(iii ) =
1 ⋅ 2 ⋅ 3 ⋅⋅⋅ ( r − 1) ⋅ r r!
n( n − 1)(n − 2) ⋅⋅⋅ ( n − r + 1)(n − r )!
=
r !( n − r )!
n!
=
r !( n − r )!
COUNTING FORMULAS:
From a given set of n distinct elements, one can choose k elements in different ways. The
number of selections of elements varies according as:
(i)elements may or may not be repeated.
(ii)the order of elements may or may not matter.
These two conditions therefore lead us to four counting methods summarized in the
following table.
ORDER ORDER
MATTERS DOES
NOT
MATTER
REPETITION k-sample k-selection
ALLOWED
REPETITION k-permutation k-
NOT combination
ALLOWED
K-SAMPLE:
A k-sample of a set of n elements is a choice of k elements taken from the set of n
elements such that the order of elements matters and elements can be repeated.
REMARK:
With k-sample, repetition of elements is allowed, therefore, k need not be less
than or equal to n. i.e. k is independent of n.
FORMULA FOR K-SAMPLE:
Suppose there are n distinct elements and we draw a k-sample from it. The first element
of the k-sample can be drawn in n ways. Since, repetition of elements is allowed, so the
second element can also be drawn in n ways.
Similarly each of third, fourth, …, k-th element can be drawn in n ways.
Hence, by product rule, the total number of ways in which a k-sample can be drawn from
n distinct elements is
n⋅n⋅n⋅…⋅n (k-times)
k
=n
EXERCISE:
How many possible outcomes are there when a fair coin is tossed three
times.
219
© Copyright Virtual University of Pakistan
30-Permutations VU
SOLUTION:
Each time a coin is tossed it’s outcome is either a head (H) or a tail (T).
Hence in successive tosses, H and T are repeated. Also the order in which they appear is
important. Accordingly, the problem is of 3-samples from a set of two elements H and T.
[k = 3, n = 2]
k
Hence number of samples =n
3
=2 =8
These 8-samples may be listed as:
HHH, HHT, HTH, THH, HTT, THT, TTH, TTT
EXERCISE:
Suppose repetition of digits is permitted.
(a)How many three-digit numbers can be formed from the six digits 2, 3, 4, 5, 7 and 9
SOLUTION:
Given distinct elements = n = 6
Digits to be chosen = k = 3
While forming numbers, order of digits is important. Also digits may be repeated.
Hence, this is the case of 3-sample from 6 elements.
k 3
Number of 3-digit numbers = n = 6 = 216
(b) How many of these numbers are less than 400?
SOLUTION:
From the given six digits 2, 3, 4, 5, 7 and 9, a three-digit number would be
less than 400 if and only if its first digit is either 2 or 3.
The next two digits positions may be filled with any one of the six digits.
Hence, by product rule, there are
2⋅6 ⋅6 = 72
three-digit numbers less than 400.
(c) How many are even?
SOLUTION:
A number is even if its right most digit is even. Thus, a 3-digit number
formed by the digits 2, 3, 4, 5, 7 and 9 is even if it last digit is 2 or 4. Thus the last digit
position may be filled in 2 ways only while each of the first two positions may be filled in
6 ways.
Hence, there are
6 ⋅ 6 ⋅ 2 = 72
3-digit even numbers.
(d) How many are odd?
SOLUTION:
A number is odd if its right most digit is odd. Thus, a 3-digit number formed
by the digits 2, 3, 4, 5, 7 and 9 is odd if its last digit is one of 3, 5, 7, 9. Thus, the last digit
position may be filled in 4 ways, while each of the first two positions may be filled in 6
ways.
Hence, there are 6 ⋅ 6 ⋅ 4 = 144
3-digit odd numbers.
220
© Copyright Virtual University of Pakistan
30-Permutations VU
(e) How many are multiples of 5?
SOLUTION:
A number is a multiple of 5 if its right most digit is either 0 or 5. Thus, a 3-
digit number formed by the digits 2, 3, 4, 5, 7 and 9 is multiple of 5 if its last digit is 5.
Thus, the last digit position may be filled in only one way, while each of the first two
positions may be filled in 6 ways.
Hence, there are 6 ⋅ 6 ⋅1 = 36
3-digit numbers that are multiple of 5.
EXERCISE:
A box contains 10 different colored light bulbs. Find the number of ordered
samples of size 3 with replacement.
SOLUTION:
Number of light bulbs = n = 10
Bulbs to be drawn = k = 3
Since bulbs are drawn with replacement, so repetition is allowed. Also while drawing a
sample, order of elements in the sample is important.
k
Hence number of samples of size 3 = n
3
= 10
= 1000
EXERCISE:
A multiple choice test contains 10 questions; there are 4 possible answers for
each question.
(a) How many ways can a student answer the questions on the test if every question is
answered?
(b) How many ways can a student answer the questions on the test if the student can leave
answers blank?
SOLUTION:
(a) Each question can be answered in 4 ways. Suppose answers are labeled as A, B, C, D.
Since label A may be used as the answer of more than one question. So repetition is
allowed. Also the order in which A, B, C, D are choosed as answers for 10 questions is
important. Hence, this is the one of k-sample, in which
n = no. of distinct labels = 4
k = no. of labels selected for answering = 10
k
∴ No. of ways to answer 10 questions = n
10
=4
= 1048576
(b)If the student can leave answers blank, then in addition to the four answers, a fifth
option to leave answer blank is possible. Hence, in such case
n=5
and k = 10 (as before)
k
∴ No. of possible answers= n
10
=5
= 9765625
221
© Copyright Virtual University of Pakistan
30-Permutations VU
k-PERMUTATION:
A k-permutation of a set of n elements is a selection of k elements taken from the set of n
elements such that the order of elements matters but repetition of the elements is not
n
allowed. The number of k-permutations of a set of n elements is denoted P(n, k) or p .
k
REMARK:
1. With k-permutation, repetition of elements is not allowed, therefore k ≤ n.
2. The wording “number of permutations of a set with n elements” means that all n
elements are to be permuted, so that k = n.
FORMULA FOR k-PERMUTATION:
Suppose a set of n elements is given. Formation of a k-permutation means that we have
an ordered selection of k elements out of n, where elements cannot be repeated.
1st element can be selected in n ways
2nd element can be selected in (n-1) ways
3rd element can be selected in (n-2) ways
………………………………….
kth element can be selected in (n-(k-1)) ways
Hence, by product rule, the number of ways to form a k-permutation is
P ( n , k ) = n ⋅ ( n − 1) ⋅ ( n − 2) ⋅ ⋅ ⋅ ( n − ( k − 1))
= n ⋅ ( n − 1) ⋅ ( n − 2) ⋅ ⋅ ⋅ ( n − k + 1)
[ n ⋅ ( n − 1) ⋅ ( n − 2) ⋅ ⋅ ⋅ ( n − k + 1)][( n − k )( n − k − 1) ⋅ ⋅ ⋅ 3 ⋅ 2 ⋅ 1]
=
[( n − k )( n − k − 1) ⋅ ⋅ ⋅ 3 ⋅ 2 ⋅ 1]
n!
=
( n − k )!
EXERCISE:
How many 2-permutation are there of {W, X, Y, Z}? Write them all.
SOLUTION:
Number of 2-permutation of 4 elements is
4 4!
P(4, 2) = p =
2 (4 − 2)!
4 ⋅ 3 ⋅ 2!
=
2!
= 4 ⋅ 3 = 12
These 12 permutations are:
WX, WY, WZ,
XW, XY, XZ,
YW, YX, YZ,
ZW, ZX, ZY.
EXERCISE:
Find (a) P(8, 3) (b) P(8,8)
(c) P(8,1) (d) P(6,8)
222
© Copyright Virtual University of Pakistan
30-Permutations VU
SOLUTION:
8!
(a ) P (8,3) = = 8 ⋅ 7 ⋅ 6 = 336
(8 − 3)!
8! 8!
(b) P (8,8) = = = 8! = 40320 ( as 0! = 1)
(8 − 8)! 0!
8! 8 ⋅ 7!
(c) P (8,1) = = =8
(8 − 1)! 7!
(d ) P (6,8) is not defined, since the second
integer cannot exceed the first integer.
EXERCISE:
Find n if
(a) P(n,2) = 72 (b) P(n,4) = 42 P (n, 2)
SOLUTION:
(a) Given P(n,2) = 72
⇒ n ⋅ (n-1) = 72 (by using the definition of permutation)
2
⇒ n -n = 72
2
⇒ n - n - 72 = 0
⇒ n = 9, -8
Since n must be positive, so the only acceptable value of n is 9.
(b) Given P(n,4) = 42P(n,2)
⇒ n (n-1) (n-2) (n-3) = 42 n (n - 1) (by using the definition of permutation)
⇒ (n-2) (n-3) = 42 if n ≠0, n ≠1
2
⇒ n - 5n + 6 = 42
2
⇒ n - 5n - 36 = 0
⇒ (n-9) (n+4) = 0
⇒ n = 9, -4
Since n must be positive, the only answer is n = 9
EXERCISE:
Prove that for all integers n ≥ 3
P (n + 1, 3) - P(n, 3) = 3 P (n, 2)
SOLUTION:
Suppose n is an integer greater than or equal to 3
Now L.H.S = P (n + 1, 3) - P(n, 3)
= (n + 1) (n) (n-1) - n (n - 1)(n - 2)
= n (n - 1) [(n + 1) - (n - 2)]
= n (n - 1) [n + 1 - n + 2]
= 3 n (n - 1)
R.H.S = 3P (n, 2)
= 3⋅n(n-1)
Thus L.H.S = R.H.S. Hence the result.
223
© Copyright Virtual University of Pakistan
30-Permutations VU
EXERCISE:
(a) How many ways can five of the letters of the word ALGORITHM be selected
and written in a row?
(b) How many ways can five of the letters of the word ALGORITHM be
selected and written in a row if the first two letters must be TH?
SOLUTION:
(a) The answer equals the number of 5-permutation of a set of 9 elements and
9!
P(9,5) = = 9 ⋅ 8 ⋅ 7 ⋅ 6 ⋅ 5 = 15120
(9 − 5)!
(b)Since the first two letters must be TH hence we need to choose the remaining three
letters out of the left 9 - 2 = 7 alphabets.
Hence, the answer is the number of 3-permutations of a set of seven elements which is
7!
P(7,3) = =7⋅6⋅5= 210
(7−3)!
EXERCISE:
Find the number of ways that a party of seven persons can arrange
themselves in a row of seven chairs.
SOLUTION:
The seven persons can arrange themselves in a row in P(7,7) ways.
Now
7! 7!
P(7,7) = = = 7!
(7 − 7)! 0!
EXERCISE:
A debating team consists of three boys and two girls. Find the number n of
ways they can sit in a row if the boys and girls are each to sit together.
SOLUTION:
There are two ways to distribute them according to sex: BBBGG or
GGBBB.
In each case
the boys can sit in a row in P(3,3) = 3! = 6 ways, and
the girls can sit in
P(2,2) = 2! = 2 ways and
Every row consist of boy and girl which is = 2!=2
Thus
The total number of ways=n = 2 ⋅ 3! ⋅ 2!
= 2 ⋅6 ⋅2 = 24
EXERCISE:
Find the number n of ways that five large books, four medium sized book,
and three small books can be placed on a shelf so that all books of the same size are
together.
224
© Copyright Virtual University of Pakistan
30-Permutations VU
SOLUTION:
In each case, the large books can be arranged among themselves in
P(5,5)= 5! ways, the medium sized books in P(4,4) = 4! ways, and the small books in
P(3,3) = 3! ways.
The three blocks of books can be arranged on the shelf in P(3,3) = 3! ways.
Thus
n = 3!⋅5! ⋅4! ⋅3!
= 103680
225
© Copyright Virtual University of Pakistan
31-Combinations VU
Lecture No.31 Combinations
K-COMBINATIONS
K-SELECTIONS
K-COMBINATIONS:
With a k-combinations the order in which the elements are selected does not matter and
the elements cannot repeat.
DEFINITION:
A k-combination of a set of n elements is a choice of k elements taken
from the set of n elements such that the order of the elements does not matter and
elements can’t be repeated.
The symbol C(n, k) denotes the number of k-combinations that can be chosen from a set
of n elements.
NOTE:
k-combinations are also written nC as or ⎛ n ⎞
k ⎜k ⎟
⎝ ⎠
REMARK:
With k-combinations of a set of n elements, repetition of elements is not
allowed, therefore, k must be less than or equal to n, i.e., k ≤ n.
EXAMPLE:
Let X = {a, b, c}. Then 2-combinations of the 3 elements of the set X are:
{a, b}, {a, c}, and {b, c}. Hence C(3,2) = 3.
EXERCISE:
Let X = {a, b, c, d, e}.
List all 3-combinations of the 5 elements of the set X, and hence find the value of C(5,3).
SOLUTION:
Then 3-combinations of the 5 elements of the set X are:
{a, b, c}, {a, b, d}, {a, b, e}, {a, c, d}, {a, c, e},
{a, d, e}, {b, c, d}, {b, c, e}, {b, d, e}, {c, d, e}
Hence C(5, 3) = 10
PERMUTATIONS AND COMBINATIONS:
EXAMPLE:
Let X = {A, B, C, D}.
The 3-combinations of X are:
{A, B, C}, {A, B, D}, {A, C, D}, {B, C, D}
Hence C(4, 3) = 4
The 3-permutations of X can be obtained from 3-combinations of X as
follows.
ABC, ACB, BAC, BCA, CAB, CBA
ABD, ADB, BAD, BDA, DAB, DBA
ACD, ADC, CAD, CDA, DAC, DCA
226
© Copyright Virtual University of Pakistan
31-Combinations VU
BCD, BDC, CBD, CDB, DBC, DCB
So that P(4, 3) = 24 = 4 · 6 = 4 · 3!
Clearly P(4, 3) = C(4, 3) · 3!
In general we have, P(n, k) = C(n, k) · k!
In general we have,
P(n, k) = C(n, k) · k!
or P ( n, k )
C ( n, k ) =
k!
But we know that n!
P ( n, k ) =
( n − k )!
n!
C ( n, k ) =
Hence, (n − k )! k !
COMPUTING C(n, k)
EXAMPLE:
Compute C(9, 6).
9!
SOLUTION: C (9,6) =
(9 − 6)!6!
9 ⋅ 8 ⋅ 7 ⋅ 6!
=
3!⋅ 6!
9 ⋅8⋅7
=
3⋅ 2
= 84
SOME IMPORTANT RESULTS
(a) C(n, 0) = 1
(b) C(n, n) = 1
(c) C(n, 1) = n
(d) C(n, 2) = n(n-1)/2
(e) C(n, k) = C(n, n – k)
(f) C(n, k) + C(n, k + 1) = C(n + 1, k + 1)
EXERCISE:
A student is to answer eight out of ten questions on an exam.
(a) Find the number m of ways that the student can choose the eight questions
(b) Find the number m of ways that the student can choose the eight questions, if the first
three questions are compulsory.
SOLUTION:
(a) The eight questions can be answered in m = C(10, 8) = 45 ways.
(b) The eight questions can be answered in m = C(7, 5) = 21 ways.
227
© Copyright Virtual University of Pakistan
31-Combinations VU
EXERCISE:
An examination paper consists of 5 questions in section A and 5 questions in
section B. A total of 8 questions must be answered. In how many ways can a student
select the questions if he is to answer at least 4 questions from section A.
SOLUTION:
There are two possibilities:
(a) The student answers 4 questions from section A and 4 questions from section B.The
number of ways 8 questions can be answered taking 4 questions from section A and 4
questions from section B are
C(5, 4) · C(5, 4) =5 · 5 = 25.
(b) The student answers 5 questions from section A and 3 questions from section B.The
number of ways 8 questions can be answered taking 5 questions from section A and 3
questions from section B are
C(5, 5) · C(5, 3) =1 · 10 = 10.
Thus there will be a total of 25 + 10 = 35 choices.
EXERCISE:
A computer programming team has 14 members.
(a) How many ways can a group of seven be chosen to work on a project?
(b) Suppose eight team members are women and six are men
(i) How many groups of seven can be chosen that contain four women and three men
(ii) How many groups of seven can be chosen that contain at least one man?
(iii)How many groups of seven can be chosen that contain at most three women?
(c) Suppose two team members refuse to work together on projects. How many groups of
seven can be chosen to work on a project?
(d) Suppose two team members insist on either working together or not at all on projects.
How many groups of seven can be chosen to work on a project?
(e) How many ways a group of 7 be chosen to work on a project?
SOLUTION:
(a) Number of committees of 7
14 !
C (14, 7 ) =
(14 − 7 ) !⋅ 7 !
14 ⋅ 13 ⋅ 12 ⋅ 11 ⋅ 10 ⋅ 9 ⋅ 8
=
7 ⋅6 ⋅5⋅4 ⋅3⋅2
= 3432
(b) Suppose eight team members are women and six are men
(i) How many groups of seven can be chosen that contain four women and three men?
SOLUTION:
Number of groups of seven that contain four women and three men.
228
© Copyright Virtual University of Pakistan
31-Combinations VU
8! 6!
C (8, 4) ⋅ C (6,3) = ⋅
(8 − 4)!⋅ 4! (6 − 3)!⋅ 3!
8⋅7 ⋅6⋅5 6 ⋅5⋅ 4
= ⋅
4! 3!
8⋅7 ⋅6⋅5 6 ⋅5⋅ 4
= ⋅
4 ⋅ 3⋅ 2 3⋅ 2
= 70 ⋅ 20 = 1400
(b) Suppose eight team members are women and six are men
(ii) How many groups of seven can be chosen that contain at least one man?
SOLUTION:
Total number of groups of seven
14!
C (14, 7) =
(14 − 7)!⋅ 7!
14 ⋅ 13 ⋅ 12 ⋅ 11 ⋅ 10 ⋅ 9 ⋅ 8
=
7 ⋅ 6 ⋅ 5⋅ 4 ⋅ 3⋅ 2
= 3432
Number of groups of seven that contain no men
8!
C (8,7) =
(8 − 7)!⋅7!
=8
Hence, the number of groups of seven that contain at least one man
C(14,7) – C(8, 7) = 3432 – 8 =3424
(b)Suppose eight team members are women and six are men
(iii) How many groups of seven can be chosen that contain atmost three women?
SOLUTION:
Number of groups of seven that contain no women = 0
Number of groups of seven that contain one woman = C(8,1) ⋅ C(6,6)
=8⋅1=8
Number of groups of seven that contain two women = C(8,2) ⋅ C(6,5)
= 28 ⋅ 6 = 168
Number of groups of seven that contain three women = C(8,3) ⋅ C(6,4)
= 56 ⋅ 15 = 840
Hence the number of groups of seven that contain at most three women
= 0 + 8 + 168 + 840 = 1016
(c) Suppose two team members refuse to work together on projects. How many groups of
seven can be chosen to work on a project?
SOLUTION:
Call the members who refuse to work together A and B.
Number of groups of seven that contain neither A nor B
229
© Copyright Virtual University of Pakistan
31-Combinations VU
12!
C (12, 7) =
(12 − 7)!⋅ 7!
Number of groups of seven
= 792 that contain A but not B
C(12, 6) = 924
Number of groups of seven that contain B but not A
C(12,6) = 924
Hence the required number of groups are
C(12,7) + C(12,6) + C(12, 6)
= 792 + 924 + 924
= 2640
(d) Suppose two team members insist on either working together or not at all on projects.
How many groups of seven can be chosen to work on a project?
SOLUTION:
Call the members who insist on working together C and D.
Number of groups of seven containing neither C nor D
C(12, 7) = 792
Number of groups of seven that contain both C and D
C(12, 5) = 792
Hence the required number
= C(12, 7) + C(12, 5)
= 792 + 792 = 1584
EXERCISE:
(a) How many 16-bit strings contain exactly 9 1’s?
(b)How many 16-bit strings contain at least one 1?
SOLUTION: 16!
(a) 16-bit strings that contain exactly 9 1’s= C (16,9) = = 11440
(16 − 9)!9!
16
(b) Total no. of 16-bit strings = 2
Hence number of 16-bit strings that contain at least one 1
16
2 – 1 = 65536 – 1
= 65535
K-SELECTIONS:
k-selections are similar to k-combinations in that the order in which the elements are
selected does not matter, but in this case repetitions can occur.
DEFINITION:
A k-selection of a set of n elements is a choice of k elements taken from a
set of n elements such that the order of elements does not matter and elements can be
repeated.
REMARK:
1. k-selections are also called k-combinations with repetition allowed or multisets of size
k.
230
© Copyright Virtual University of Pakistan