Introduction
Combinatorics answers "how many?" without listing. How many passwords of a given form exist, how many ways can tasks be assigned to processors, how many paths cross a grid, how many binary strings avoid a pattern? Counting is the basis of discrete probability (favourable outcomes over total outcomes), of the analysis of algorithms (number of comparisons, number of possible inputs), and of many recurrences.
The topics are the basic principles, permutations and combinations with and without repetition, the binomial theorem, distributions of objects into boxes, inclusion-exclusion, derangements, the pigeonhole principle, and the Catalan numbers.
Prerequisites
Core concepts
The basic principles
- Sum rule. If a task can be done in one of ways or one of ways, with no way common to both, there are ways. (For disjoint sets, .)
- Product rule. If a task is a sequence of two steps, with ways for the first and, for each of them, ways for the second, there are ways. (.)
- Subtraction rule. when the cases overlap.
- Complement rule. Count what you do not want and subtract from the total. For "at least one", use the complement.
- Division rule. If every outcome of interest is counted exactly times, divide by . (Circular arrangements, unordered pairs.)
- Bijection rule. If the objects can be put in one-to-one correspondence with objects that are easier to count, the counts are equal.
Permutations and combinations
| Selection of from distinct objects | Order matters | Order does not matter |
|---|---|---|
| Without repetition | ||
| With repetition allowed |
Here in the first row (otherwise the count is 0); in the second row any is allowed.
- (" choose ") counts -element subsets. : choose the set, then order it.
- Permutations of a multiset. The number of distinct arrangements of objects with of type 1, , of type () is the multinomial coefficient
Example: arrangements of MISSISSIPPI (1 M, 4 I, 4 S, 2 P) .
- Circular arrangements. distinct people around a round table, where rotations are the same: . If reflections are also the same (necklaces of distinct beads): for .
The binomial theorem and identities
For any and integer :
Standard identities (all for integers , with when or ):
| Identity | Statement |
|---|---|
| Symmetry | |
| Pascal | for |
| Row sum | |
| Alternating sum | for |
| Weighted sum | |
| Vandermonde | |
| Squares | |
| Hockey stick |
The coefficient of in with is ; in the coefficient of is .
Distributing objects into boxes (stars and bars)
Stars and bars. The number of solutions of in non-negative integers is
Reason: arrange stars and bars in a row; the bars cut the stars into groups, possibly empty. Any arrangement is a choice of bar positions among .
- In positive integers (): substitute , giving .
- With lower bounds : subtract from first.
- With upper bounds : use inclusion-exclusion over the variables that exceed their bounds (Example 3).
- Inequality : add a slack variable , giving .

The twelvefold summary (the common cases). For and , distributing objects into boxes:
| Objects | Boxes | Any number per box | At least one per box | At most one per box |
|---|---|---|---|---|
| Distinct | Distinct | |||
| Identical | Distinct | |||
| Distinct | Identical | 1 if , else 0 | ||
| Identical | Identical | partitions of into at most parts | partitions of into exactly parts | 1 if , else 0 |
With and for , is the Stirling number of the second kind, the number of ways to partition an -set into non-empty blocks, with . is the number of onto functions (see Functions).
Inclusion-exclusion
For finite sets :
The number of elements in none of the sets is , where is the size of the universe. If every intersection of sets has the same size (the symmetric case), the count of elements in none of them is with .

Derangements
A derangement is a permutation with no fixed point (no element in its original position). Their number is
Values: . is the nearest integer to for , so the probability that a random permutation is a derangement tends to . The number of permutations with exactly fixed points is .
The pigeonhole principle
If objects go into boxes, some box holds at least objects. To guarantee that some box holds at least objects, objects are needed and enough.
Catalan numbers
counts: balanced strings of pairs of parentheses; binary trees with nodes (structurally distinct); full binary trees with leaves; ways to parenthesise a product of factors; lattice paths from to with unit right and up steps that never go above the diagonal; triangulations of a convex -gon; valid stack-permutation sequences of pushes and pops. They satisfy .
Lattice paths without the diagonal restriction: from to with right and up steps there are paths.
Worked examples
Example 1: committees
From 6 men and 5 women, choose a committee of 4 with at least one woman. Total ; all-men ; answer . (Adding "choose one woman, then any 3 others" gives , which overcounts.)
Example 2: strings
Binary strings of length 10 with exactly four 1s: . With at least two 1s: . Strings over of length 5 containing at least one : .
Example 3: stars and bars with an upper bound
Number of non-negative integer solutions of with every . Without bounds: . If , set : solutions; same for . Two variables cannot both be at least 5 unless the third is 0 and both equal 5: for each pair. Three: impossible.
(They are the arrangements of and : .)
Example 4: inclusion-exclusion on permutations
How many permutations of have none of the patterns "12", "34" or "56" as consecutive entries? Gluing of the three pairs into blocks leaves units, so each -fold intersection has permutations:
Example 5: derangements
Five letters are placed at random into their five addressed envelopes. The number of ways in which no letter is in its correct envelope is ; exactly two correct: .
Important properties and observations
- is largest at (and ).
- counts -subsets, binary strings with ones, and monotone lattice paths with up-steps among steps; switching between these views solves many problems.
- (combinations with repetition) equals the stars-and-bars count with types and items: choosing donuts from kinds.
- Number of subsets of an -set with even size for .
- Number of diagonals of a convex -gon: . Number of intersection points of diagonals (no three concurrent): .
GATE examination perspective
- Identify the model first. Ordered or not, repetition or not, distinct or identical objects and boxes. Choose the row of the tables above first.
- "At least" problems. Use complements; avoid "choose one, then the rest", which overcounts.
- Equation-solution counts. Stars and bars, with inclusion-exclusion for upper bounds.
- Derangements and Catalan numbers. Know the first values; recognise Catalan structures (balanced parentheses, binary trees, stack sequences).
- Numerical-answer questions. Compute carefully; check with a smaller instance where you can list the cases.
- Trap: circular arrangements: , not ; necklaces also divide by 2.
Summary
Sources
- K. H. Rosen, Discrete Mathematics and Its Applications, 7th ed., McGraw-Hill, 2012: Chapter 6 (Counting) and Sections 8.5 and 8.6 (Inclusion-Exclusion and its applications).