Act fast, special offers end soon! Up to $294 is savings when you get Premium today.
Get offer codes

What exactly is "Ordering" in Permutations?

Screen Link:

On the last screen, we used the extended rule of product and saw we have 10,000 possible 4-digit PIN codes:
Number of outcomes=10⋅10⋅10⋅10=10,000
Each PIN code represents a certain arrangement where the order of the individual digits matters. Because order matters, the code 1289 is different than the code 9821, even though both are composed of the same four digits: 1, 2, 8 and 9. If the order of digits didn’t matter, 1289 would be the same as 9821.

The above is an excerpt taken from the lesson in the link. It highlights that when considering the permutations, the order matters. However, I am at a loss as to how the “Ordering” is written in to the formula.

Specifically, whether I choose 1,2,8,9 or 9,8,2,1. The number of outcomes is 10*10*10*10. The position of the numbers 1,2,8 or 9 are not considered in the formula.

So how is ordering represented in formula?

(To bring more clarity to where I’m coming from)
The formula for Combinations is clear in this regard because its only about the ‘Unique Counts’. Combinations basically counts the number of unique counts of permutations.


Here C represents the unique counts and the 5! manages the permutations. So this is quite clear. I however did not get the same clarity for the permutation formula with regards to where ordering fits in.

The doubt came up while I was doing the problems in Learn data science with Python and R projects

This can be confusing, for sure.

The “ordering” is very much defined by the problem statement you have. If you have a pin code for your phone to unlock it, then you can’t enter 1234 if your code is 3412. The same set of digits but the order is different.

But, in general, if a phone accepts a 4 digit code to unlock it, there are 10,000 possible 4-digit numbers because each number is a valid option in that regard because for the defined problem, the order matters.

You have 10000 outcomes because the order matters when you have a 4 digit code. 1234 is a different outcome than 3412.

So, given the above what would be the scenario if the order did not matter?

Well, if the order did not matter, you could pick 1234 or 3412 or 1324 and other variants of those 4 digits and say “any one of them can be the correct code”.

The above would make more sense if looked at from the perspective of probability. Note the use of the word outcome might make things a bit confusing here, but it’s based on what you have covered in previous lessons.

What would be the probability of selecting the correct 4-digit code out of 10,000 4-digit numbers?

  • If the order matters, then you have 1 successful outcome and 10000 total number of possible outcomes. So, the probability is 1/10000.
  • If the order does not matter, then you have N successful outcomes and 10000 total number of possible outcomes. The probability is N/10000.

So, how the problem is defined very much plays a part in this. It’s more clear when the problem statement is framed as -

Given n, select k

Let’s consider a different example now.

You have a group of 3 people playing some sport. Out of those 3 you need to select a captain and a vice-captain.

Let’s simplify this visually, to an extent. The 3 people are - A, B, C. You need to select a captain and a vice-captain.

What all possible ways can that happen?

  • A, B
  • A, C
  • B, C

Now, you might think -

A was captain and B was vice-captain. But B could have been captain and A could be vice-captain.

A different way to state the above could also be -

We selected a captain first then the vice-captain. But we could have selected the vice-captain first then the captain.

And you would be absolutely correct. The order of selection matters here.

So, the above changes to -

  • A, B
  • B, A
  • B, C
  • C, B
  • A, C
  • C, A

The above permutations are possible because the order of our selection matters and each possible outcome is a valid option. There are 6 ways we can select a captain and vice-captain out of a group of 3.

Let’s change our problem statement just a little bit.

The 3 people are - A, B, C. You need to select any two people.

What all possible ways can that happen?

  • A, B
  • A, C
  • B, C

Again, you might think

But what about B, A?

Well, we are just selecting two people out of three. It doesn’t matter if we pick A first or B. The order does not matter here. There are 3 ways we can pick any two people out of a group of three.

As per me, this is a difficult concept to grasp. I have struggled with this as well (and still do at times). It will take time and practice to understand it better to get to an intuitive level. Hopefully, the above helps a bit. If the above is still confusing or I made a mistake somewhere, let me know.

1 Like

Excellent explanation @the_doctor :grinning: . Thank you for putting in time to provide the same. :+1:

Before you had replied I had read the additional resources provided at the end of the lesson. This with your explanation has solidified my understanding.

I think the problem with using numbers to explain the concept of ordering is what creates the confusion, at least it did for me. Numbers and alphabets have a homogeneous nature. When you think of 1210 and 2110 both are numbers albeit different. However the concept of ordering would not stick.

After reading your example I thought of a class of 10 students.

students = [Amanda, Darcy, Arun, Faiza, Shelby, Lenny, Trio, Zia, Retsy, Min]

Say the scenario was that I had to select three students from the class of 10 for the roles of President, V. President and Treasurer with the powers of those roles being in the order given i.e President being most powerful and Treasurer being the least.

If I had to find out the number of ways this selection could be done I would use Permutation because here order matters. i.e. the permutations would include subsets like (among others):

Darcy, Arun, Faiza,
Darcy, Faiza, Arun
Arun, Faiza, Darcy
Arun, Darcy, Faiza
Faiza, Darcy, Arun
Faiza, Arun, Darcy

In each of these permutations the order matters. Where in one Faiza could be a President, in another, she could be a V.P and yet in another she could be a Treasurer. Here the Order matters.

Contrast this to the scenario wherein you have to divide the class to teams of 5. Assume that the team member do not have any specific roles. Some of the different combinations (among others) would be:

Amanda, Darcy, Arun, Faiza, Shelby
Lenny, Trio, Zia, Retsy, Min
Darcy, Arun, Faiza, Shelby, Lenny

Now since the combination Lenny, Trio, Zia, Retsy, Min has been considered we do not need to have another combination with the same set of people i.e Trio, Zia, Min, Lenny, Retsy because its still the same team and there is no Order to be considered here.

To solidify the understanding, if there was a stipulation that each team has to have a team captain then we would move to find the permutations because having Lenny as captain for the team Lenny, Trio, Zia, Retsy, Min would be different to having Trio being captain of the same team.