**Prerequisite –** Combinatorics Basics

Several **Counting problems** require finding the number of ways to arrange a certain number of distinct elements, where the relative order of these elements matter, other problems focus on finding the number of ways of selecting a particular number of elements from a set, where the order of the elements does not matter. Both types of problems are similar except for one crucial difference, that difference is **order**.

### Permutation –

A permutation of a set of distinct objects is an ordered arrangement of these objects. A permutation is often also referred to as an arrangement. The relative order of the elements matters in an arrangement.

An ordered arrangement of elements of a set is called an **r-permutation**. It is represented as .

For ,

The above formula for is a simple application of the **product-rule**.

**Example 1 –**How many permutations of the string “ABCDEFGH” have the string “ABC” as a substring?**Solution –**For “ABC” to be a substring, the letters A,B, and C must occur as a block. If we consider that block and the remaining 5 letters as objects, we have a total of 6 objects to arrange.

Therefore the number of strings having “ABC” as their substring = 6! = 720.**Example 2 –**Find the number of permutations of the word “CIVILIZATION”.**Solution –**The word civilization has the following character frequency-

‘C’ – 1

‘I’ – 4

‘V’ – 1

‘L’ – 1

‘Z’ – 1

‘A’ – 1

‘T’ – 1

‘O’ – 1

‘N’ – 1

If all the characters were distinct, the number of permutations would be where = 12. But since the letter ‘I’ repeats 4 times, the number of permutations are less. This is because the permuation as a whole does not change if the ‘I’s’ are arranged amongst themselves. So to correct the number of permutations, we divide the total permutations by where is the number of times a letter or object is repeated.

Total number of arrangements =

### Combination –

A combination of a set of distinct objects is just a count of the number of ways a specific number of elements can be selected from a set of a certain size. The order of elements does not matter in a combination.

An unordered selection of elements from a set is called an **r-combination**. It is represented as and .

Since a combination is just a permutation without order, the number of -combination can be expressed in terms of -permutation.

The -permutation can be obtained by first obtaining the -combination and then ordering the elements in each -combination, which can be done in ways.

which gives us-

**Example 1 –**Determine the number of ways in which 5 cards can be chosen from a deck of 52 cards, such that there is exactly one ace.**Solution –**Out of the 4 aces, one can be chosen in ways.

The remaining 4 cards have to be chosen from the remaining 48 cards. Number of ways of choosing these 4 cards is .

Total number of ways of choosing 5 cards by product rule = = 4 * 194580 = 778320.**Example 2 –**A polygon has 44 diagnols. Find the number of its sides.**Solution –**A diagnol is a line which connects two non-adjacent vertices. If is the number of vertices, then the number of pairs of non-adjacent vertices = . is subtracted since there are sides.

Therefore number of diagnols = number of non-adjacent vertices

On solving we get = 11.

### Binomial Coefficients –

The -combinations from a set of elements if denoted by . This number is also called a binomial coefficient since it occurs as a coefficient in the expansion of powers of binomial expressions.

The binomial theorem gives a power of a binomial expression as a sum of terms involving binomial coefficients.

Formally,

Let and be variables and be a non-negative integer. Then

**Example 1 –**What is the coefficient of in the expansion of ?**Solution –**.

By the binomial theorem-

Since the power of is 13, .

Therefore the coefficient of is-**Example 2 –**Prove that .**Solution –**If we put and in the binomial theorem expression, we get-**Example 3 –**Prove that .**Solution –**If we put and in the binomial theorem expression, we get-**Example 4 –**Prove that .**Solution –**If we put and in the binomial theorem expression, we get-

**GATE CS Corner Questions**

Practicing the following questions will help you test your knowledge. All questions have been asked in GATE in previous years or in GATE Mock Tests. It is highly recommended that you practice them.

Questions 1 and 2 are related.

1. GATE CS 2007, Question 84

2. GATE CS 2007, Question 85

3. GATE CS 2003, Question 4

4. GATE CS 2003, Question 5

**References-**

Discrete Mathematics and its Applications, by Kenneth H Rosen

This article is contributed by **Chirag Manwani**. If you like GeeksforGeeks and would like to contribute, you can also write an article using contribute.geeksforgeeks.org or mail your article to contribute@geeksforgeeks.org. See your article appearing on the GeeksforGeeks main page and help other Geeks.

Please write comments if you find anything incorrect, or you want to share more information about the topic discussed above.