# Discrete Mathematics - Counting Theory

In daily lives, many a times one needs to find out the number of all possible outcomes for a series of events. For instance, in how many ways can a panel of judges comprising of 6 men and 4 women be chosen from among 50 men and 38 women? How many different 10 lettered PAN numbers can be generated such that the first five letters are capital alphabets, the next four are digits and the last is again a capital letter. For solving these problems, mathematical theory of counting are used. Counting mainly encompasses fundamental counting rule, the permutation rule, and the combination rule.

## The Rules of Sum and Product

The Rule of Sum and Rule of Product are used to decompose difficult counting problems into simple problems.

• The Rule of Sum − If a sequence of tasks $T_1, T_2, \dots, T_m$ can be done in $w_1, w_2, \dots w_m$ ways respectively (the condition is that no tasks can be performed simultaneously), then the number of ways to do one of these tasks is $w_1 + w_2 + \dots +w_m$. If we consider two tasks A and B which are disjoint (i.e. $A \cap B = \emptyset$), then mathematically $|A \cup B| = |A| + |B|$

• The Rule of Product − If a sequence of tasks $T_1, T_2, \dots, T_m$ can be done in $w_1, w_2, \dots w_m$ ways respectively and every task arrives after the occurrence of the previous task, then there are $w_1 \times w_2 \times \dots \times w_m$ ways to perform the tasks. Mathematically, if a task B arrives after a task A, then $|A \times B| = |A|\times|B|$

### Example

Question − A boy lives at X and wants to go to School at Z. From his home X he has to first reach Y and then Y to Z. He may go X to Y by either 3 bus routes or 2 train routes. From there, he can either choose 4 bus routes or 5 train routes to reach Z. How many ways are there to go from X to Z?

Solution − From X to Y, he can go in $3 + 2 = 5$ ways (Rule of Sum). Thereafter, he can go Y to Z in $4 + 5 = 9$ ways (Rule of Sum). Hence from X to Z he can go in $5 \times 9 = 45$ ways (Rule of Product).

## Permutations

A permutation is an arrangement of some elements in which order matters. In other words a Permutation is an ordered Combination of elements.

### Examples

• From a set S ={x, y, z} by taking two at a time, all permutations are −

$xy, yx, xz, zx, yz, zy$.

• We have to form a permutation of three digit numbers from a set of numbers $S = \lbrace 1, 2, 3 \rbrace$. Different three digit numbers will be formed when we arrange the digits. The permutation will be = 123, 132, 213, 231, 312, 321

### Number of Permutations

The number of permutations of ‘n’ different things taken ‘r’ at a time is denoted by $n_{P_{r}}$

$$n_{P_{r}} = \frac{n!}{(n - r)!}$$

where $n! = 1.2.3. \dots (n - 1).n$

Proof − Let there be ‘n’ different elements.

There are n number of ways to fill up the first place. After filling the first place (n-1) number of elements is left. Hence, there are (n-1) ways to fill up the second place. After filling the first and second place, (n-2) number of elements is left. Hence, there are (n-2) ways to fill up the third place. We can now generalize the number of ways to fill up r-th place as [n – (r–1)] = n–r+1

So, the total no. of ways to fill up from first place up to r-th-place −

$n_{ P_{ r } } = n (n-1) (n-2)..... (n-r + 1)$

$= [n(n-1)(n-2) ... (n-r + 1)] [(n-r)(n-r-1) \dots 3.2.1] / [(n-r)(n-r-1) \dots 3.2.1]$

Hence,

$n_{ P_{ r } } = n! / (n-r)!$

### Some important formulas of permutation

• If there are n elements of which $a_1$ are alike of some kind, $a_2$ are alike of another kind; $a_3$ are alike of third kind and so on and $a_r$ are of $r^{th}$ kind, where $(a_1 + a_2 + ... a_r) = n$.

Then, number of permutations of these n objects is = $n! / [(a_1!(a_2!) \dots (a_r!)]$.

• Number of permutations of n distinct elements taking n elements at a time = $n_{P_n} = n!$

• The number of permutations of n dissimilar elements taking r elements at a time, when x particular things always occupy definite places = $n-x_{p_{r-x}}$

• The number of permutations of n dissimilar elements when r specified things always come together is − $r! (n−r+1)!$

• The number of permutations of n dissimilar elements when r specified things never come together is − $n!–[r! (n−r+1)!]$

• The number of circular permutations of n different elements taken x elements at time = $^np_{x}/x$

• The number of circular permutations of n different things = $^np_{n}/n$

### Some Problems

Problem 1 − From a bunch of 6 different cards, how many ways we can permute it?

Solution − As we are taking 6 cards at a time from a deck of 6 cards, the permutation will be $^6P_{6} = 6! = 720$

Problem 2 − In how many ways can the letters of the word 'READER' be arranged?

Solution − There are 6 letters word (2 E, 1 A, 1D and 2R.) in the word 'READER'.

The permutation will be $= 6! /\: [(2!) (1!)(1!)(2!)] = 180.$

Problem 3 − In how ways can the letters of the word 'ORANGE' be arranged so that the consonants occupy only the even positions?

Solution − There are 3 vowels and 3 consonants in the word 'ORANGE'. Number of ways of arranging the consonants among themselves $= ^3P_{3} = 3! = 6$. The remaining 3 vacant places will be filled up by 3 vowels in $^3P_{3} = 3! = 6$ ways. Hence, the total number of permutation is $6 \times 6 = 36$

## Combinations

A combination is selection of some given elements in which order does not matter.

The number of all combinations of n things, taken r at a time is −

$$^nC_{ { r } } = \frac { n! } { r!(n-r)! }$$

Problem 1

Find the number of subsets of the set $\lbrace1, 2, 3, 4, 5, 6\rbrace$ having 3 elements.

Solution

The cardinality of the set is 6 and we have to choose 3 elements from the set. Here, the ordering does not matter. Hence, the number of subsets will be $^6C_{3} = 20$.

Problem 2

There are 6 men and 5 women in a room. In how many ways we can choose 3 men and 2 women from the room?

Solution

The number of ways to choose 3 men from 6 men is $^6C_{3}$ and the number of ways to choose 2 women from 5 women is $^5C_{2}$

Hence, the total number of ways is − $^6C_{3} \times ^5C_{2} = 20 \times 10 = 200$

Problem 3

How many ways can you choose 3 distinct groups of 3 students from total 9 students?

Solution

Let us number the groups as 1, 2 and 3

For choosing 3 students for 1st group, the number of ways − $^9C_{3}$

The number of ways for choosing 3 students for 2nd group after choosing 1st group − $^6C_{3}$

The number of ways for choosing 3 students for 3rd group after choosing 1st and 2nd group − $^3C_{3}$

Hence, the total number of ways $= ^9C_{3} \times ^6C_{3} \times ^3C_{3} = 84 \times 20 \times 1 = 1680$

## Pascal's Identity

Pascal's identity, first derived by Blaise Pascal in 17th century, states that the number of ways to choose k elements from n elements is equal to the summation of number of ways to choose (k-1) elements from (n-1) elements and the number of ways to choose elements from n-1 elements.

Mathematically, for any positive integers k and n: $^nC_{k} = ^n{^-}^1C_{k-1} + ^n{^-}^1{C_k}$

Proof

$$^n{^-}^1C_{k-1} + ^n{^-}^1{C_k}$$

$= \frac{ (n-1)! } { (k-1)!(n-k)! } + \frac{ (n-1)! } { k!(n-k-1)! }$

$= (n-1)!(\frac{ k } { k!(n-k)! } + \frac{ n-k } { k!(n-k)! } )$

$= (n-1)! \frac{ n } { k!(n-k)! }$

$= \frac{ n! } { k!(n-k)! }$

$= n_{ C_{ k } }$

## Pigeonhole Principle

In 1834, German mathematician, Peter Gustav Lejeune Dirichlet, stated a principle which he called the drawer principle. Now, it is known as the pigeonhole principle.

Pigeonhole Principle states that if there are fewer pigeon holes than total number of pigeons and each pigeon is put in a pigeon hole, then there must be at least one pigeon hole with more than one pigeon. If n pigeons are put into m pigeonholes where n > m, there's a hole with more than one pigeon.

### Examples

• Ten men are in a room and they are taking part in handshakes. If each person shakes hands at least once and no man shakes the same man’s hand more than once then two men took part in the same number of handshakes.

• There must be at least two people in a class of 30 whose names start with the same alphabet.

## The Inclusion-Exclusion principle

The Inclusion-exclusion principle computes the cardinal number of the union of multiple non-disjoint sets. For two sets A and B, the principle states −

$|A \cup B| = |A| + |B| - |A \cap B|$

For three sets A, B and C, the principle states −

$|A \cup B \cup C | = |A| + |B| + |C| - |A \cap B| - |A \cap C| - |B \cap C| + |A \cap B \cap C |$

The generalized formula -

$|\bigcup_{i=1}^{n}A_i|=\sum\limits_{1\leq i<j<k\leq n}|A_i \cap A_j|+\sum\limits_{1\leq i<j<k\leq n}|A_i \cap A_j \cap A_k|- \dots +(-1)^{\pi-1}|A_1 \cap \dots \cap A_2|$

Problem 1

How many integers from 1 to 50 are multiples of 2 or 3 but not both?

Solution

From 1 to 100, there are $50/2 = 25$ numbers which are multiples of 2.

There are $50/3 = 16$ numbers which are multiples of 3.

There are $50/6 = 8$ numbers which are multiples of both 2 and 3.

So, $|A|=25$, $|B|=16$ and $|A \cap B|= 8$.

$|A \cup B| = |A| + |B| - |A \cap B| = 25 + 16 - 8 = 33$

Problem 2

In a group of 50 students 24 like cold drinks and 36 like hot drinks and each student likes at least one of the two drinks. How many like both coffee and tea?

Solution

Let X be the set of students who like cold drinks and Y be the set of people who like hot drinks.

So, $| X \cup Y | = 50$, $|X| = 24$, $|Y| = 36$

$|X \cap Y| = |X| + |Y| - |X \cup Y| = 24 + 36 - 50 = 60 - 50 = 10$

Hence, there are 10 students who like both tea and coffee.