The combination is a way of choosing items from a set, such (unlike permutations) the order of selection doesn’t matter. In smaller cases, it’s possible to count the amount of combinations. Combination refers to the mixture of n things taken k at a time without repetition. To know the combinations in the case where the repetition is allowed, the terms like k-selection or k-combination along with repetition are often used. For instance, if we’ve two elements A and B, then there’s just one way to select two items, we select both of them.
Number of combinations when ‘r’ elements are selected out of a complete set of ‘n’ elements is nCr = n! / [(r !) x (n – r)!]. For example, let n = 4 (E, F, G, H) and r = 2 (consisting of all the combinations of size 2). The answer is 4!/((4-2)!*2!) = 6. The six combinations are EF, EG, EH, FG, FH, GH.
A combination is that the choice of r things from a group of n things without replacement and where order doesn’t matter.
Briefly, a combination refers to the choice of r things from a set of n things made without making any replacement and where order does not matter.
Formula of combination
What is Handshaking Problem?
How many handshakes does it take for everybody to shake everybody else’s hand? If you have a room full of people, how many handshakes are required for everybody to shake everybody else’s hand exactly once? Example as in the small group.
Two People: A-B 1 handshake
Three People: A-B 3 handshake
Four People: A-B
A-D 6 handshake
This basically means that when there are 2 people there will be two handshakes and if there are three people there will be 3 handshakes and so on. This much of people we can count but let’s suppose there are thousands of people in a hall then we can’t count each handshake here is the need for the combination arises.
It means the total number of people in a room done the handshake with each other. With the help of combination, we can calculate it in a very simple way. Formula for calculating the handshakes
Total = n × (n – 1)/2
Total number of handshakes = nC2
Sample Problems on Combinations
Various handshaking problems are in circulation in every day of life, the most common one being the following:
Problem 1: In a room of n people, how many handshakes are possible?
To see the people present, and consider one person at a time. The first person will shake hands with n – 1 other people. The next person will shake hands with n-2 other people, not counting the first person again. Following this, it will give us a total number of
(n – 1) + (n – 2) + … + 2 + 1
= n(n – 1)/ 2 handshakes.
Problem 2: Another popular handshake problem starts out similarly with n>1 people at a party. Not being possible to shake hands with yourself, and not counting it several times handshakes with the same person, the problem is to show that there will always present two people in the party, who had shaken hands at the same number of times in the party.
The solution to this problem starts by using Dirichlet’s box principle. If there exists a person at the party, who has shaken hands zero times, then every person which is there at the party has shaken hands with at most n-2 other people at the party.
There are n-1 possible handshakes (from 0 to n-2), among n people there must be two who have shaken hands the same number of times. If there are zero persons, who has shaken hands zero times this means that all of the party guests have shaken hands at least once.
This also amounts to n-1 possible handshakes (from 1 to n-1).
Problem 3: In the function, if every person shakes hand with every other in the party and there exists a total of 28 handshakes at the party, find the number of persons who were present in the function?
Solution: Suppose there are n persons present at a party and every person shakes hand with every other person.
Then, total number of handshakes = nC2 = n(n – 1)/2
n(n – 1)/2 = 28
n(n – 1) = 28 × 2
n(n – 1) = 56
n = 8
Problem 4: As is typical for problems with big numbers, you should always resort to a smaller number if you can’t solve the full problem. Here, 17 people at the table are a bit hard to assume immediately. Let’s start with 3 people at the table. How many handshakes now?
There are zero. So now the question arises,
What about 4 people:
A can’t shake with B or C, B can’t with A or D, D can’t with B or C, C can’t with A or D–only A & D and B & C can shake.
So 2 shakes:
5 people are when it gets some interest, and when you should be able to see the pattern forming:
Everyone has 2 people and that can not shake hands with, leaving those two shakes per person, but we overcount by just multiplying 5 & 3, now we have to divide by two.
This is easiest to draw a line between any people who can shake hands:
A———–C (also C-D & A-E–a 5-point star)
So we hypothesize the answer is n(n – 3)/2. Note that the formula only holds for n = 3 and n = 4 as well
One final way to look at this is to look at the graphs again you might notice that they were always a complete graph (every vertex connected to every other vertex) with the outer edges of the graph removed.
Since there are n(n-1)/2 edges in a complete graph on n vertices in which the n outer edges,
There must be n(n – 1)/2 – n = n2−n−2n/2 = n(n – 3)/2 handshakes.
However you cut it, there are 17⋅14/2 = 119 total handshakes.
Problem 5: At a party, every person shakes hand with each other person. If there was a total of 26 handshakes done at the party, how many persons were present at the party?
Suppose there are n persons present in a party and every person shakes hand with every other person in the party. Then, total number of handshakes will be counted as = nC2 = n(n – 1)/2
n(n – 1)/2 = 29
n(n – 1) = 26 × 2
n(n – 1) = 52
n = 8 Persons
Problem 6: 20 people shake hands with each other. How many handshakes will be there in total?
We know the total number of persons in the party is 20, so every person shakes hands with other 19 persons.
We can have the solution directly also as, 20 × 19 = 380 handshakes.
But by every handshake two persons are involved.
380/2 = 190 handshakes
But according to the formula,
n = total number of persons
r = number of handshakes
n = 20
r = 2
Inputting in the formula we should have;
n! / (n – r)! r!
= 20! / (20 – 2)! 2!
= 20!/18! 2!
= 20 × 19 × 18! / 18!2!
= 20 × 19/12!
= 380/2 × 1
= 190 handshakes
Attention reader! Don’t stop learning now. Get hold of all the important DSA concepts with the DSA Self Paced Course at a student-friendly price and become industry ready.