Lesson 8-Basics of Counting, Permutations & Combinations
Lesson 8-Basics of Counting, Permutations & Combinations
Combinations
The techniques needed to answer this question and a wide variety of other 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.
We will introduce the basic techniques of counting in this section. These methods serve as the
foundation for almost all counting techniques.
The rule of product states that if there are ways of doing something, and ways of doing
another thing after that, then there are ways to perform both of these actions. In other
words, when choosing an option for and an option for , there are different ways to
do both actions.
1
THE PRODUCT RULE:
Suppose that a procedure can be broken down into a sequence of two tasks. If there are n 1
ways to do the first task and for each of these ways of doing the first task, there are n2 ways to
do the second task, then there are n1 n2 ways to do the procedure.
Example 8.1.1
Lily is trying to decide what to wear. She has shirts in the following colors: red, purple, and
blue, and she has pants in the following colors: black and white. How many different outfits
can Lily choose from (assuming she selects one shirt and one pair of pants)?
Solution:
From the definition of the rule of product, if there are options for doing one thing (like
choosing a shirt), and options for doing another thing (like choosing a pair of pants), then
there are total combinations we can choose from. In this case, there are 3 options for
choosing a shirt, and there are 2 options for choosing pants. Thus, there are 3 2 = 6 total
options.
Here is a table where each row represents a possible outfit.
Shirt Pants
Red Black
Blue Black
Purple Black
Red White
Blue White
Purple White
Example 8.1.2
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 elements in the codomain for each of
the elements in the domain. Hence, by the product rule there are =
functions from a set with m elements to one with n elements. For example, there are
different functions from a set with three elements to a set with five elements.
2
Example 8.1.3
There are 32 microcomputers in a computer center. Each microcomputer has 24 ports. How
many different ports to a microcomputer in the center are there?
Solution:
The procedure of choosing a port consists of two tasks, first picking a microcomputer and
then picking a port on this microcomputer. Because there are 32 ways to choose the micro-
computer and 24 ways to choose the port no matter which microcomputer has been selected,
the product rule shows that there are 32 24 = 768 ports.
Example 8.1.4
How many one-to-one functions are there from a set with m elements to one with n elements?
Solution:
First note when there are no one-to-one functions from a set with m elements to a set
with n elements.
Now let . Suppose the elements in the domain are . There are n ways to
choose the value of the function at . Because the function is one-to-one, the value of the
function at can be picked in ways (because the value used for cannot be used
again). In general, the value of the function at can be chosen in ways. By the
product rule, there are ( ) one-to-one functions from a set with
m elements to one with n elements.
For example, there are = 60 one-to-one functions from a set with three elements to
a set with five elements.
3
Example 8.1.5
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 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 a 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.
Adding the number of ways to do the tasks in these two ways leads to an over count, because
the ways to do the task in the ways that are common are counted twice. To correctly count the
number of ways to do the two tasks, we add the number of ways to do it in one way and the
number of ways to do it in the other way, and then subtract the number of ways to do the task
in a way that is both among the set of n1 ways and the set of n2 ways.
This technique is called the principle of inclusion-exclusion. Sometimes, it is also called the
subtraction principle for counting. This was done under the section pertaining to sets.
Let A1 and A2 be sets. There are | | ways to select an element from A1 and | | ways to
select an element from A2. The number of ways to select an element from A1 or from A2, that
is, the number of ways to select an element from their union, is the sum of the number of
ways to select an element from A1 and the number of ways to select an element from A2,
minus the number of ways to select an element that is in both A1 and A2. Thus we have
| |=| | | | | |
4
8.1.2 Tree Diagrams
Counting problems can be solved using tree diagrams. A tree consists of a root, a number of
branches leaving the root, and possible additional branches leaving the end points of other
branches.
To use trees in counting, we use a branch to represent each possible choice. We represent the
possible outcomes by the leaves, which are the endpoints of branches not having other
branches starting at them. Figure 1 displays this scenario.
Root
Branch
Leaves
Example 8.1.5
How many bit strings of length four do not have two consecutive ones?
Solution:
We start with the first bit. We have two options, 1 or 0. Then we move on to the second bit. If
the first bit was 1 then the only option for the second bit is 0. Since if it were to be 1 then it
would contradict the question at hand. Likewise if the second bit was 0 then again we have
two options, either 1 or 0.In a similar fashion we obtain the options available for the third and
fourth bits. Hence finally we arrive at the answer as 8 bit strings.
Note that when a tree diagram is used to solve a counting problem, the number of choices
required to reach a leaf can vary. Figure 2 displays all possible choices.
5
Figure 2: Bit Strings of Length Four
without Consecutive 1s.
2. In New Hampshire, license plates consisted of two letters followed by 3 digits. How
many possible license plates are there?
3. A student can choose one computer project from one of three lists. The three lists contain
23, 15 and 19 possible choices. How many possible projects are there to choose from?
6
8.3 Permutations and Combinations
Introduction
Many counting problems can be solved by finding the number of ways to arrange a specified
number of distinct elements of a set of a particular size, where the order of these elements
matters.
Many other counting problems can be solved by finding the number of ways to select a
particular number of elements from a set of a particular size, where the order of the elements
selected does not matter.
For example, in how many ways can we select three students from a group of five students to
stand in line for a picture? How many different committees of three students can be formed
from a group of four students? In this section we will develop methods to answers questions
such as these.
8.3.1 Combinations
A combination is simply a manner of selecting some objects from a given set of objects in
such a way that the order of their selection doesn’t matter. It is also assumed that one is not
selecting a single item more than once. i.e. repetitions are not allowed.
The formula for this notation is:
n!
n
Cr
r !(n r )!
where n! is the factorial of the number n, given as n! =
This is only valid when n > r.
Example 8.2.1
A magic show has ten people in the audience. For the next act, the magician needs two
people from the audience. In how many ways can he invite the two people from his audience?
Solution:
What we mean by the number of ways is actually how many different pairs of people can he
invite up to the stage. For e.g. suppose that we have five friends Tim, John, Robin, Alice and
Sarah in the audience along with five other people.
Now, the magic trick can be conducted equally well by inviting say, John and Alice to the
stage; as well as by inviting Tim and Robin to the stage. Thus, we need to find out the
7
number of all such pairs which can lead to a success of the magic trick.
We must choose 2 people out of the total 10 people. Thus, according to the formula; we
have n = 10 and r=2. Then,
10!
10
C2
2!(10 2)!
It can be solved by expanding the factorial in the numerator:
10! 10 9 8 7 6 5 4 3 2 1
10
C2 45
2!8! 2 1 8 7 6 5 4 3 2 1
Hence there are 45 ways in which the magician can select two people from his audience of
ten. This is what you mean by the number of combinations of two people from a total of ten
people.
8.3.2 Permutations
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.
Analysis
Let‟s say we have a set of „n‟ distinct objects, out of which we must choose „r‟ objects. We
can proceed in the following two ways of choosing the required objects:
8
Case 1: When the repetition of objects is allowed
When choosing „r‟ objects from the set of „n‟ objects we have n choices available to us „r‟
times.
Since this event is taking place „r‟ times and the act of choosing an object from the available
set is always independent of our other choices, we may invoke the Product Rule of Counting
here. Using the fundamental principle then, we get,
𝑃 𝑛 𝑟 = 𝑛𝑟
This is the permutation formula for the number of permutations possible for the choice of „r‟
objects from a set of „n‟ distinct objects when repetition is allowed.
In this case, we must be careful, not to choose a specific object more than once. Hence our
choices after each event get reduced by one. For example, when we begin choosing our first
object, we have all the „ ‟ choices available to us.
In the next event, however, we have „ ‟ objects available for choice, since we must not
include the object that we have already chosen in the first step. Similarly, for the third step,
we have „ ‟ objects available to us. Thus, from the Product Rule of Counting, we get
Example 8.2.1
In a sports broadcasting company, the manager must pick the top three goals of the month,
from a list of ten goals. In how many ways can the top three goals be decided?
Solution:
Picking up three goals from a list of ten:
9
Example 8.2.2
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. Consequently, the answer is
100
P3 = 100 ·99 · 98 = 970,200
Suggested Readings:
Chapter 5: Sections 5.1 & 5.3, Kenneth Rosen, (2011) Discrete Mathematics and Its
Applications, 7th Edition, McGraw-Hill Education
10