DM - Unit 3 (Counting) - Notes
DM - Unit 3 (Counting) - Notes
Introduction
Suppose that a password on a computer system consists of six, seven, or eight characters.
Each of these characters must be a digit or a letter of the alphabet. Each password must
contain at least one digit. How many such passwords are there?
The techniques needed to answer this question and a wide variety of counting problems
will be introduced in this section.
Counting problems arise throughout mathematics and computer science.
For example, we must count the successful outcomes of experiments and all the possible
outcomes of these experiments to determine probabilities of discrete events. We need to
count the number of operations used by an algorithm to study its time complexity.
Product Rule:
Suppose that a procedure can be broken down into a sequence of two tasks. If there are n
ways to do the first task and for each of these ways of doing the first task, there are m
ways to do the second task, then there are n*m ways to do the procedure.
Example 1: A new company with just two employees, rents a floor of a building with 12
offices. How many ways are there to assign different offices to these two employees?
Solution:
Step 1: Break the procedure into tasks
Task 1: assigning an office to employee 1
Task 2: assigning an office to employee 2
Step 2: Count different ways of doing each task and then use the product rule
Task 1 can be done in 12 different ways and for each of these ways, Task 2 can be
done in 11 different ways.
By product rule, There are 12·11 = 132 ways to assign offices to two employees.
Example 2: The chairs of an auditorium are to be labeled with a letter and a positive
integer not exceeding 100. How many chairs can be labeled differently?
Solution:
Step 1: Break the procedure into tasks
Task 1: assigning one of the 26 letters
Task 2: assigning one of the 100 possible integers
Step 2: Count different ways of doing each task and then use the product rule
Task 1 can be done in 26 different ways and for each of these ways, Task 2 can be
done in 100 different ways.
By product rule, There are 26·100 = 2600 ways to assign labels to the chairs.
Example 4: An office building contains 27 floors and has 37 offices on each floor. How
many offices are there in building?
Example 5: There are 18 mathematics majors and 325 computer science majors at a
college. In how many ways can two representatives be picked so that one is mathematics
major and the other is a computer science major?
Solution: By product rule: There are 18 • 325= 5850 ways to pick the two
representatives.
Example 6: Six different airlines fly from New York to Denver and seven fly from
Denver to San Francisco. How many different pairs of airlines can you choose on which
to book a trip from New York to San Francisco via Denver, when you pick an airline for
the flight to Denver and an airline for the continuation flight to San Francisco?
Solution: By the product rule: flight is determined by choosing an airline for the flight
from New York to Denver (which can be done in 6 ways) and then choosing an airline for
the flight from Denver to San Francisco (which can be done in 7 ways).
Therefore there are 6 • 7 = 42 different possibilities for the entire flight.
Example 7: How many different bit strings of length seven are there?
Solution:
Step 1: Break the procedure into tasks
Task 1: assigning bit 1 to 0 or 1
Task 2: assigning bit 2 to 0 or 1
…
Task 7: assigning bit 7 to 0 or 1
Step 2: Count different ways of doing each task and then use the product rule
Each task can be done in 2 different ways.
By product rule, there are 27= 128 different bit strings of length seven.
Example 8: How many different license plates are available if each plate contains a
sequence of three letters followed by 3 digits?
Solution:
Step 1: Break the procedure into tasks
Task 1: choose letter 1 (26 possible ways)
Task 2: choose letter 2 (26 possible ways)
Task 3: choose letter 3 (26 possible ways)
Task 4: choose digit 1 (10 possible ways)
Task 5: choose digit 2 (10 possible ways)
Task 6: choose digit 3 (10 possible ways)
Step 2: Count different ways of doing each task and then use the product rule
There are 26 choices for each of the three uppercase English letters and ten
choices for each of the three digits. Hence, by the product rule there are a total of
26·26·26·10·10·10= 17,576,000 possible license plates.
Example 9: A particular brand of shirt comes in 12 colors, has a male & a female
version, & comes in 3 sizes for each sex. How many different types of this shirt are
made?
Solution: By product rule shows that there 12*2*3=72 different types of shirt.
Example 10: How many functions are there from a set with m elements to a set with n
elements?
Solution:
Step 1: Break the procedure into tasks
Task: Assign an element in codomain to element ai in domain. For all i=1,2,…,m.
i.e for each of the m elements in the domain, there are n choices from the
codomain.
Step 2: Count different ways of doing each task and then use the product rule
By product rule, there are n·n·n····n =nm different functions.
In the new plan, the format of telephone numbers is NXX-NXX-XXXX. How many
North American telephone numbers are possible under the old plan and under the new
plan?
Solution: By the product rule, there are 8·2·10=160 area codes with format NYX and
8·10·10=800 area codes with format NXX.
Similarly, by the product rule, there are 8·8·10=640 office codes with format NNX.
The product rule also shows that there are 10·10·10·10=10,000 station codes with format
XXXX.
Consequently, applying the product rule again, it follows that under the old plan there are
160·640·10,000=1,024,000,000 different numbers available in North America.
Under the new plan, there are 800·800·10,000=6,400,000,000 different numbers available
Example 12: In how many ways can we select 3 students from a group of 5 students to
stand in line for a picture? In how many ways can we arrange all 5 of these students in a
line for a picture?
Solution: Note that the order in which we select the students matters. There are five ways
to select the first student to stand at the start of the line. Once this student has been
selected, there are four ways to select the second student in the line. After the first and
second students have been selected, there are three ways to select the third student in the
line.
By the product rule, there are 5·4·3=60 ways to select three students from a group of five
students to stand in line for a picture.
To arrange all five students in a line for a picture, we select the first student in five ways,
the second in four ways, the third in three ways, the fourth in two ways, and the fifth in
one way. Consequently, there are 5·4·3·2·1 = 120 ways to arrange all five students in a
line for a picture.
Sum Rule:
Example 13: Suppose that either a member of the mathematics faculty or a student who
is 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 and no one is both a faculty member and
a student?
Solution: There are 37 ways to choose a member of the mathematics faculty and there are
83 ways to choose a student who is mathematics major. Choosing a member of the
mathematics faculty is never the same as choosing a student who is mathematics major
because no one is both a faculty member and a student. By the sum rule it follows that
there are 37 + 83 = 120 possible ways to pick this representative.
Example 14: A student can choose a computer project from one of three lists. The three
lists contain 23, 15, and 19 possible projects, respectively. No project is on more than one
list. How many possible projects are there to choose from?
Solution: The student can choose a project by selecting a project from the first list, the
second list, or the third list. Because no project is on more than one list, by the sum rule
there are 23 + 15 + 19 = 57 ways to choose a project.
Example 15: A university consists only of 2 faculties, namely Science and Engineering.
On Tuesday at 11am there are 10 exams that can take place from the faculty of Science.
At the same time there are 5 exams that can take place from the faculty of Engineering.
How many possible exams can take place?
Solution: For University there are 10 + 5 = 15 exams that can take place.
Example 18: How many bit strings of length eight either start with a 1 bit or end with
two bits 00?
Solution:
Task 1: choose a bit string of length eight starts with 1.
Task 2: choose a bit string of length eight ends with 00.
Since the first bit must be 1 in task 1, by the product rule, the number of task 1 is 27.
Since the last two bits must be 00 in task 2, by the product rule, the number of task 2
is 26.
The strings of length eight that start with 1 and end 00 are common in task 1 and task
2 and the number of them are 25.
By inclusion-exclusion principles, the number of such strings is 27+ 26- 25 = 160.
Example 20: A computer company receives 350 applications for a job. Suppose that 220
of them majored in computer science, 147 of them majored in business and 51 of them
majored both in computer science and business. How many of these applicants majored in
neither computer science nor business?
Solution:
First find the number of applicants that are majored in computer science or business, then
subtract it from the total number of applicants
Task 1: choose an applicant majored in computer science
Task 2: choose an applicant majored in business.
The number of task 1 is 220.
The number of task 2 is 147.
The applicants that are majored both in computer science and business are common in
task 1 and task 2 and the number of them are 51.
By inclusion-exclusion principles, the number of task 1 and task 2 is 220 + 147-51 =
316.
So, the number of applicants majored in neither computer science and business is
350 - 316=34.
Example 21: There are 18 mathematics majors and 325 computer science majors at a
college.
a) In how many ways can two representatives be picked so that one is a mathematics
major and the other is a computer science major?
b) In how many ways can one representative be picked who is either a mathematics
major or a computer science major?
Solution: a)
There are 18 ways to choose the mathematics major.
There are 325 ways to choose the computer science major.
By the product rule, 18*325 = 5850 ways to pick the two representatives.
Solution: b)
There are 18 ways to choose mathematics major, and there are 325 ways to choose a
computer science major.
By sum rule, there are 18 + 325 = 343 ways to pick the representative.
Permutations
The act of arranging all the members of a set into some sequence or order T. OR
An arrangement in sequence of elements of a set is called a permutation of the element.
In a permutation, the order that we arrange the objects in is important.
Example 22: Consider arranging 3 letters: A, B, C. How many ways can this be done?
Solution: The possible permutations are:
ABC, ACB, BAC, BCA, CAB, CBA.
Hence, there are six distinct arrangements.
Another way of looking at this question is by drawing 3 boxes.
Any one of the A, B, C goes into the first box (3 ways to do this), and then the remaining
one of the two letters goes into the second box (2 ways to do this), and the last remaining
letter goes into the third box (only one way left to do this).
Hence, Total no of ways = 3 × 2 × 1 = 6.
Theorem II: Number of permutations of „n‟ different things taken „r‟ at a time is given
by:-
n
Pr = ( )
(n and r are integers with 0 ≤ r ≤ n)
Proof:
Say we have „n‟ different things a1, a2……, an.
Clearly the first place can be filled up in ‘n’ ways. Number of things left after filling-
up the first place = (n-1).
So the second-place can be filled-up in (n-1) ways. Now number of things left after
filling-up the first and second places = (n – 2)
Now the third place can be filled-up in (n-2) ways.
Thus Number of ways of filling-up rth place = n – (r - 1) = n - r + 1
By product rule of counting, total no. of ways of filling up, first, second rth place
together :- n (n-1) (n-2) ------------ (n - r + 1)
Hence:
n
Pr = n (n-1)(n-2) --------------(n - r + 1)
When n and r are integers with 1 ≤ r ≤ n, by Theorem 1 we have
P (n, r) = n (n − 1) (n – 2) ··· (n – r + 1) = n!/(n-r)!
Because n!/(n-0)! = n!/n! =1 whenever n is a nonnegative integer.
n
Pr = ( )
0≤r≤n Hence proved
Theorem III: Number of permutations of „n‟ different things taken all at a time is given
by:- nPn = n!
n
Proof: We have Pr = n!/(n-r)! Putting r = n, we have,
n
Pn = n! / (n-n)! = n!/0! Since 0!= 1 we have
n
Pn = n! Hence proved
Example 23: In how many ways can a supermarket manager display 5 brands of biscuits
in 3 spaces on a shelf?
Solution: This is asking for the number of permutations, since we don't want repetitions.
n
The number of ways is: Pr = n!/(n-r)! = 5!/(5-3)! = 5!/2! = 60
Example 24: How many ways are there to select a first-prize winner, a second-prize
winner, and a third-prize winner from 100 different people who have entered a contest?
Solution: Because it matters which person wins which prize, the number of ways to pick
the three prize winners is the number of ordered selections of three elements from a set of
100 elements, that is, the number of 3-permutations of a set of 100 elements.
Example 25: How many different number-plates for cars can be made if each number-
plate contains four of the digits 0 to 9 followed by a letter A to Z, assuming that no
repetition of digits is allowed?
Solution: There are 10 possible digits (0, 1, 2… 9) and we need to take them 4 at a time.
n
There are 26 letters in the alphabet. Pr = n!/(n-r)!
10
P4 * 26 = [10!/(10-4)! ] * 26 = 131040.
Example 26: How many four digit number can be formed out of digits 1 to 9 if
a) No repetition is permitted & b) How many of these will be greater than 3000.
Solution: a) There are 9 possible digits (1, 2,…, 9) and we need to take them 4 at a time.
n
Pr = n!/(n-r)!
9
P4 = [9!/(9-4)! ] = 9!/5!= 3024
b) There is restriction that the four digit numbers so formed must be greater than 3000.
Therefore 1000th position can be filled with numbers 3,4,5,6,7,8,9 i.e. by 7 different ways,
100th position can be filled with 8 different ways, 10th place can be filled with 7 different
ways, Unit place can be filled with 6 different ways. Thus, 7 * 8 * 7 * 6 = 2352 ways.
Example 28: How many three digit numbers can be formed with the digits: 1, 2, 3, 4, 5?
Solution: n = 5 r = 3. The order of the elements does matter. The elements are repeated.
P(n,r)= nr i.e. P(5,3) = 53 = 125
Example 29: How many 3 digit numbers can be formed with the digits: 0, 1, 2, 3, 4, 5?
Solution: n = 6 r = 3. The numbers must be separated into two blocks:
The first set, of one number, can occupy only one of 5 digits because a number does not
begin with zero (except for license plates and other special cases).
n=5 r=1
The second block, of two numbers, can occupy any digit. n = 6 r=2
P(n,r)= nr i.e. P(5,1). P(6,2) = 51 . 62 = 180.
Example 30: How many ordered arrangements are there of the letters in the word
PHILIPPINES?
Solution: The number of ordered arrangements of the letters in the word PHILIPPINES
is:
Example 31: The signal mast of a ship can raise nine flags at one time (three red, two
blue and four green). How many different signals can be communicated by the placement
of these nine flags?
Solution: n = 9 r1 = 3, r2 = 2, r3 = 4, r1 + r2 + r3 = 9.
Example 32: How many nine-digit numbers can be formed with the numbers 2, 2, 2, 3, 3,
3, 3, 4, 4?
Solution: n = 9 r1 = 3, r2 = 4, r3 = 2, r1 + r2 + r3 = 9.
The order of the elements does matter. The elements are repeated.
Example 33: Fifteen (15) animals are available to use in a study to compare three (3)
different diets. Each of the diets (let's say, A, B, C) is to be used on five randomly
selected animals. In how many ways can the diets be assigned to the animals?
Solution: Well, one possible assignment of the diets to the animals would be for the first
five animals to be placed on diet A, the second five animals to be placed on diet B, and
the last 5 animals to be placed on diet C. That is:
A A A A A B B B B B C C C C C
Another possible assignment might look like this:
A B C A B C A B C A B C A B C
Upon studying these possible assignments, we see that we need to count the number of
distinguishable permutations of 15 objects of which 5 are of type A, 5 are of type B, and 5
are of type C. Using the formula, we see that there are:
Example 34: A ship's captain sends signals by arranging 4 orange and 3 blue flags on a
vertical pole. How many different signals could the ship's captain possibly send?
Solution. If the flags were numbered 1, 2, 3, 4, 5, 6 and 7, then the orange flags and blue
flags would be distinguishable among themselves. In that case, the ship's captain could
send any of 7! = 5,040 possible signals.
The flags are not numbered, however. That is, the four orange flags are not
distinguishable among themselves, and the 3 blue flags are not distinguishable among
themselves. We need to count the number of distinguishable permutations when the two
colors are the only features that make the flags distinguishable. The ship's captain has 4
orange flags and 3 blue flags. Using the formula for the number of distinguishable
permutations, the ship's captain could send any of:
Example 35: Suppose we toss a gold dollar coin 8 times. What is the probability that the
sequence of 8 tosses yields 3 heads (H) and 5 tails (T)?
Solution: Two such sequences, for example, might look like this:
H H H T T T T T or this HTHTHTTT
Assuming the coin is fair, and thus that the outcomes of tossing either a head or tail are
equally likely, we can use the classical approach to assigning the probability. The Product
Rule: 2 × 2 × 2 × 2 × 2 × 2 × 2 × 2 = 256 possible outcomes in the sample space of 8
tosses.
Now, when counting the number of sequences of 3 heads and 5 tails, we need to
recognize that we are dealing with arrangements or permutations of the letters, since order
matters, but in this case not all of the objects are distinct. We can think of choosing (note
that choice of word!) r = 3 positions for the heads (H) out of the n = 8 possible tosses.
That would, of course, leave then n − r = 8 − 3 = 5 positions for the tails (T). Using the
formula for a combination of n objects taken r at a time, there are therefore:
Distinguishable permutations of 3 heads (H) and 5 tails (T). The probability of tossing 3
heads (H) and 5 tails (T) is thus 56/256 = 0.22.
Example 36: In how many ways can 4 married couples attending a concert be seated in a
row of 8 seats:
a) if there are no restrictions as to where the 8 people can sit?
b) if each married couple is seated together?
c) if members of the same sex are all seated next to each other
Solution: a) Here are the eight seats:
If we arbitrarily name the people A, B, C, D, E, F, G, and H, then one possible seating
arrangement is ABCDEFGH. Another is DGHCAEBF.
These examples suggest that we have to place 8 people into 8 seats without repetition. i.e,
one person can't occupy two seats!
The Product Rule: 8 × 7 × 6 × 5 × 4 × 3 × 2 × 1 = 40,320 possible seating arrangements.
b) Here are the eight seats shown as four paired seats:
If we arbitrarily name the people A1, A2, B1, B2, C1, C2, D1, and D2, then one possible
seating arrangement is B2, B1, A1, A2, C2, C1, D1, D2. Another such assignment might
be B1, B2, A2, A1, C1, C2, D1, D2. These two examples illustrate that counting here is a
two-step process.
Permuting 4 items (couples) 4 at a time... there are 4! Ways.
Then, we have to arrange the partners within each couple. Well, couple A can be
arranged 2! ways. We can even list the ways... they can sit either as A1, A2 or as A2, A1.
Likewise, couple B can be arranged in 2! ways, as can couples C and D. The Product
Rule then tells us to multiply all the numbers together. Four married couples can be
seated in a row of 8 seats in: 4! × 2! × 2! × 2! × 2! = 384 ways if each married couple is
seated together.
c) If we arbitrarily name the people M1, M2, M3, M4 and F1, F2, F3, F4, then one
possible seating arrangement is M1, M2, M4, M3, F2, F1, F3, F4. Another such
assignment might be F1, F2, F4, F3, M2, M1, M4, M3.
Again, these two examples illustrate that counting here is a two-step process. First, we
have to figure out how many ways the genders M and F can be arranged. There are, of
course, 2 ways... the males in the seats on the left and females in the seats on the right or
the females in the seats on the left and the males in the seats on the right. Then, we have
to arrange the people within each gender. Let's take the females first. Permuting 4 items
(females) 4 at a time... there are 4! ways. Likewise, there are 4! ways of arranging the
males within their 4 seats. The Product Rule then tells us to multiply all the numbers
together. Four married couples can be seated in a row of 8 seats in: 4! × 4! × 2 = 1,152
ways if the members of the same sex are seated next to each other.
Example 37: In how many ways can 6 people be seated at a round table?
Solution: The number of ways will be (6 – 1)!, or 120.
Example 38: Find the number of ways in which 5 people A,B,C,D,E can be seated at a
round table, such that
(i) A and B must always sit together. And (ii) C and D must not sit together.
Solution: (i) If we wish to seat A and B together in all arrangements, we can consider
these two as one unit, along with 3 others. So effectively we‟ve to arrange 4 people in a
circle, the number of ways being (4 – 1)! or 6.
But in each of these arrangements, A and B can themselves interchange places in 2 ways.
Therefore, the total number of ways will be 6 x 2 = 12.
(ii) The number of ways in this case would be obtained by removing all those cases (from
the total possible) in which C & D are together. The total number of ways will be (5 – 1)!
or 24.
Similar to (i) above, the number of cases in which C & D are seated together, will be 12.
Therefore the required number of ways will be 24 – 12 = 12.
Example 39: In how many ways can 3 men and 3 ladies be seated at around table such
that no two men are seated together?
Solution: Since we don‟t want the men to be seated together, the only way to do this is to
make the men and women sit alternately.
We‟ll first seat the 3 women, on alternate seats, which can be done in (3 – 1)! or 2 ways,
as shown below. (We‟re ignoring the other 3 seats for now)
That is, if each of the women is shifted by a seat in any direction, the seating arrangement
remains exactly the same. i.e why we have only 2 arrangements, Now that we‟ve done
this, the 3 men can be seated in the remaining seats in 3! or 6 ways. Note that we haven‟t
used the formula for circular arrangements now. This is so because, after the women are
seated, shifting the each of the men by 2 seats, will give a different arrangement. After
fixing the position of the women (same as „numbering‟ the seats), the arrangement on the
remaining seats is equivalent to a linear arrangement.
Therefore the total number of ways in this case will be 2! X 3! = 12.
Example 40: 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 41: 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 42: Suppose that a saleswoman has to visit eight different cities. She must
begin her trip in a specified city, but she can visit the other seven cities in any order she
wishes. How many possible orders can the saleswoman use when visiting these cities?
Solution: The number of possible paths between the cities is the number of permutations
of seven elements, because the first city is determined, but the remaining seven can be
ordered arbitrarily. Consequently, there are 7! = 7 · 6 · 5 · 4 · 3 · 2 · 1 = 5040 ways for the
saleswoman to choose her tour. If, for instance, the saleswoman wishes to find the path
between the cities with minimum distance, and she computes the total distance for each
possible path, she must consider a total of 5040 paths!
Example 43: In how many ways can this diagram be coloured subject to the following
two conditions?
(i) Each of the smaller triangle is to be painted with one of three
colours: red, blue or green.
(ii) No two adjacent regions have the same colour.
Solution: These conditions are satisfied exactly when we do as
follows: First paint the central triangle in any one of the three colours. Next paint the
remaining 3 triangles, with any one of the remaining two colours.
By the fundamental principle of counting, this can be done in 3 × 2 × 2 × 2 = 24 ways.
Example 44: How many numbers are there between 99 and 1000 having 7 in the units
place?
Solution: First note that all these numbers have three digits. 7 is in the unit‟s place. The
middle digit can be any one of the 10 digits from 0 to 9.
The digit in hundred‟s place can be any one of the 9 digits from 1 to 9.
Therefore, by the fundamental principle of counting, there are 10 × 9 = 90 numbers
between 99 and 1000 having 7 in the unit‟s place.
Example 45: How many numbers are there between 99 and 1000 having atleast one of
their digits 7?
Solution: Total number of 3 digit numbers having atleast one of their digits as 7 = (Total
numbers of three digit numbers) – (Total number of 3 digit numbers in which 7 does not
appear at all).
= (9 × 10 × 10) – (8 × 9 × 9) = 900 – 648 = 252.
Example 46: How many ways are there to rearrange the letters in the word COMPUTER
Solution: There are 8 distinct letters in the word COMPUTER. Therefore, 8!
Example 47: How many ways if you are required to keep the vowels in alphabetical
order in the word COMPUTER? (In other words, the consonants can be in any order at
all, but the vowels must appear in the order EOU, possibly with consonants in between
the vowels.)
Solution: There are 5 consonants and 8 positions to choose from. The number of ways to
permutate this is 8 × 7 × 6 × 5 × 4 = 6720. There is only 1 way to arrange the vowels in
the remaining 3 positions (namely, in the order E, O and U). Therefore, the
number of arrangements given the constraints is 6720.
Example 48: How many ways if the consonants must be kept in alphabetical order in the
word COMPUTER?
Solution: 5! ways to permutate the consonants in the word. Therefore, the number of
ways to arrange COMPUTER, keeping the consonants in in alphabetical order is 8!/5!
= 336.
Example 49: Find the number of ways in which 10 beads can be arranged to form a
necklace.
Solution: Let us fix the position of one bead. Now, we are left with the arrangement of
the remaining, 10 − 1 = 9 beads. These nine beads can arrange themselves in 9P9 = 9!
ways. As there is no dependency on the position of beads in a clockwise or anticlockwise
manner. The required number of ways = 1/2 (9!) = 181440.
Example 50: In how many ways can 5 children be arranged in a line such that (i) two
particular children of them are always together (ii) two particular children of them are
never together.
Solution: (i) We consider the arrangements by taking 2 particular children together as
one and hence the remaining 4 can be arranged in 4! = 24 ways. Again two particular
children taken together can be arranged in two ways. Therefore, there are 24 × 2 = 48
total ways of arrangement.
(ii) Among the 5! = 120 permutations of 5 children, there are 48 in which two children
are together. In the remaining 120 – 48 = 72 permutations, two particular children are
never together.
Example 51: If all permutations of the letters of the word AGAIN are arranged in the
order as in a dictionary. What is the 49th word?
Solution: Starting with letter A, and arranging the other four letters, there are 4! = 24
words. These are the first 24 words.
Then starting with G, and arranging A, A, I and N in different ways, there are 4!/2!1!1!
= 12 words.
Next the 37th word starts with I. There are again 12 words starting with I. This accounts
up to the 48th word. The 49th word is NAAGI.
Example 52: One hundred tickets, numbered 1, 2, 3, . . . , 100, are sold to 100 different
people for a drawing. Four different prizes are awarded, including a grand prize (a trip to
Tahiti).How many ways are there to award the prizes if
a) there are no restrictions?
b) the person holding ticket 47 wins the grand prize?
c) the person holding ticket 47 wins one of the prizes?
d) the person holding ticket 47 does not win a prize?
e) the people holding tickets 19 and 47 both win prizes?
f ) the people holding tickets 19, 47, and 73 all win prizes?
g) the people holding tickets 19, 47, 73, and 97 all win prizes?
h) none of the people holding tickets 19, 47, 73, and 97 wins a prize?
i) the grand prize winner is a person holding ticket 19, 47, 73, or 97?
j) the people holding tickets 19 and 47 win prizes, but the people holding tickets 73 and
97 do not win prizes?
Combinations
In mathematics, a combination is a selection of items from a collection, such that (unlike
permutations) the order of selection does not matter.
For example, given three fruits, say an apple, an orange and a pear, there are three
combinations of two that can be drawn from this set: an apple and a pear; an apple and an
orange; or a pear and an orange.
More formally, a k-combination of a set S is a subset of k distinct elements of S. If the
set has n elements, the number of k-combinations is equal to the binomial coefficient:
When computing C(n, r), first note that when we cancel out (n − r)! from the numerator
and denominator of the expression for C(n, r) in Theorem I, we obtain
Example 53: How many poker hands of five cards can be dealt from a standard deck of
52 cards? Also, how many ways are there to select 47 cards from a standard deck of 52
cards?
Solution: Because the order in which the five cards are dealt from a deck of 52 cards
does not matter, there are:
C(52, 5) = =
different poker hands of five cards that can be dealt from a standard deck of 52 cards.
Also,
C(52, 47) = =
Property: Let n and r be nonnegative integers with r ≤ n. Then C(n, r) = C(n, n − r).
Proof: We have,
C(n, r) = ( )
Then,
Example 54: How many ways are there to select five players from a 10-member tennis
team to make a trip to a match at another school?
Solution: The answer is given by the number of 5-combinations of a set with 10
elements.
C(10, 5) =
Example 55: A group of 30 people have been trained as astronauts to go on the first
mission to Mars. How many ways are there to select a crew of six people to go on this
mission (assuming that all crew members have the same job)?
Solution: The number of ways to select a crew of six from the pool of 30 people is the
number of 6-combinations of a set with 30 elements, because the order in which these
people are chosen does not matter. By Theorem 2, the number of such combinations is
C(30, 6) =
No of Sample = C(52, 5) =
No of Sample = C(52, 5) =
Example 57: In a lottery, each ticket has 5 one-digit numbers 0-9 on it.
a) You win if your ticket has the digits in any order. What are your chances of winning?
b) You would win only if your ticket has the digits in the required order. What are your
chances of winning?
Prof. S. B. Shinde [MES College of Engineering, Pune] Page 22
Discrete Mathematics: Unit 3
Solution:
There are 10 digits to be taken 5 at a time.
B. Type II: Combination with Repetition: The number of ways to fill r slots from n
categories with repetition allowed is: C(r + n − 1, r) = C (r + n −1, n−1).
Example 58: How many ways can I fill a box holding 100 pieces of candy from 30
different types of candy?
Solution: Here r = 100, n = 30, Therefore n-1 = 30-1 = 29
C(r + n − 1, r) = C (r + n −1, n−1).
C(100 + 29,100) = 129!/(100!29!) Different ways to fill the box.
Example 59: What is the number of ways of choosing 4 cards from a pack of 52 playing
card? In how many of these
a) Four cards are of the same suit
b) Four cards belong to four different suit
c) Are face cards
d) Two are red cards and two are black cards
e) Cards of same colour
Solution: a) There are four suits and 13 cards of each suit
Cards Total No. of cards to be chosen No. of ways
Diamond 13 4 C(13, 4)
Spade 13 4 C(13, 4)
Heart 13 4 C(13, 4)
Club 13 4 C(13, 4)
Total number of ways of choosing two are red cards and two are black cards
=C(26,2) * C(26,2) = (C(26,2))2 = 105625.
e) Cards of same colour
Cards Total No. of cards to be chosen No. of ways
Red 26 4 C(26, 4)
Black 26 4 C(26, 4)
More Examples:
Example 1: In a class, there are 27 boys and 14 girls. The teacher wants to select 1 boy
and 1 girl to represent the class for a function. In how many ways can the teacher make
this selection?
Solution: Here the teacher is to perform two operations:
(i) Selecting a boy from among the 27 boys and
(ii) Selecting a girl from among 14 girls.
The first of these can be done in 27 ways and second can be performed in 14 ways. By the
fundamental principle of counting, the required number of ways is 27 × 14 = 378.
Example 3: In how many ways 3 mathematics books, 4 history books, 3 chemistry books
and 2 biology books can be arranged on a shelf so that all books of the same subjects are
together.
Solution: First we take books of a particular subject as one unit. Thus there are 4 units
which can be arranged in 4! = 24 ways. Now in each of arrangements, mathematics books
can be arranged in 3! ways, history books in 4! ways, chemistry books in 3! ways and
biology books in 2! ways. Thus the total number of ways = 4! × 3! × 4! × 3! × 2! = 41472.
Example 4: A student has to answer 10 questions, choosing atleast 4 from each of Parts
A and B. If there are 6 questions in Part A and 7 in Part B, in how many ways can the
student choose 10 questions?
Solution: The possibilities are: 4 from Part A and 6 from Part B or 5 from Part A and 5
from Part B or 6 from Part A and 4 from Part B. Therefore, the required number of ways
is: 6C4 × 7C6 + 6C5 × 7C5 + 6C6 × 7C4 = 105 + 126 + 35 = 266.
Example 5: In a small village, there are 87 families, of which 52 families have atmost 2
children. In a rural development programme 20 families are to be chosen for assistance,
of which atleast 18 families must have at most 2 children. In how many ways can the
choice be made?
Solution: It is given that out of 87 families, 52 families have at most 2 children so other
35 families are of other type. According to the question, for rural development
programme, 20 families are to be chosen for assistance, of which at least 18 families must
have atmost 2 children. Thus, the following are the number of possible choices:
52C18*35C2 (18 families having atmost 2 children and 2 selected from other type of
families)
52C19*35C1 (19 families having atmost 2 children and 1 selected from other type of
families)
52C20 (All selected 20 families having atmost 2 children)
Hence, the total number of possible choices is = 52C18 × 35C2 + 52C19 × 35C1 + 52C20
Example 6: A boy has 3 library tickets and 8 books of his interest in the library. Of these
8, he does not want to borrow Mathematics Part II, unless Mathematics Part I is also
borrowed. In how many ways can he choose the three books to be borrowed?
Solution: Let us make the following cases:
Case (i) Boy borrows Mathematics Part II, then he borrows Mathematics Part I also.
Example 7: Coin Flipping Model If I flip a coin 20 times, I get a sequence of Heads (H)
and tails (T).
How many different sequences of heads and tails are possible?
How many different sequences of heads and tails have exactly five heads?
How many different sequences have at most 2 heads?
How many different sequences have at least three heads?
Solution:
(a) There are 2 ways the first flip can come up; 2 more for the second and so on. Hence 2 ·
· · 2 = 2 20 = 1, 048, 576.
(b) The actual answer to our problem is C(20, 5) = 15, 504.
(c) C(20, 0) + C(20, 1) + C(20, 2) = 1 + 20 + 190 = 211
(d) C(20, 3) + C(20, 4) + · · · + C(20, 19) + C(20, 20).
OR 220 − [C(20, 0)+C(20, 1)+C(20, 2)] = 1, 048, 576−211 = 1, 048, 365.