Engineering Mathematics
Combinatorics
Build counting templates so permutations, combinations, and inclusion–exclusion become pattern recognition — then lock marks with GATE-style NATs and MCQs.
GATE CSE combinatorics — permutations, combinations, pigeonhole, inclusion–exclusion, recurrences, sample GATE questions, flashcards, and practice drills.
Learning outcomes
- Choose permutation vs combination correctly from the stem
- Apply pigeonhole and inclusion–exclusion without overcounting
- Set up and solve standard linear recurrence relations
- Solve GATE-style counting MCQ/NAT items with a clear explanation trail
Permutations & combinations
- P(n,r) = n!/(n−r)! when order matters; C(n,r) = n!/(r!(n−r)!) when order does not.
- With repetition: n^r arrangements of length r from n types; combinations with repetition C(n+r−1, r) (stars and bars).
- Circular permutations of n distinct objects: (n−1)!. Fix one seat to remove rotational symmetry.
- Identical objects: for multiset with repeats n1, n2, … divide by n1! n2! …
- Binomial identity C(n,r) = C(n,n−r) and Pascal: C(n,r) = C(n−1,r) + C(n−1,r−1) appear in quick checks.
Formulas to remember
-
P(n,r) = n!/(n−r)! -
C(n,r) = n!/(r!(n−r)!) -
Combinations with repetition: C(n+r−1, r) -
Distinct permutations of multiset: n! / (n1! n2! …)
| Situation | Use | Formula cue |
|---|---|---|
| Ordered selection, no repeat | Permutation | P(n,r) |
| Unordered selection, no repeat | Combination | C(n,r) |
| Ordered, repeats allowed | Words / functions | n^r |
| Unordered, repeats allowed | Stars and bars | C(n+r−1,r) |
Worked example
Problem. How many distinct words can be formed by rearranging letters of GATE?
Solution. 4 distinct letters → 4! = 24. If a letter repeats (e.g. GATECSE later), divide by factorials of repeat counts.
Pigeonhole principle
- Basic: n+1 pigeons into n holes ⇒ some hole has ≥2.
- Generalized: n pigeons, k holes ⇒ some hole has ≥ ceil(n/k).
- To guarantee at least r in one hole: worst case (r−1) per hole, then +1 → k(r−1)+1.
- Classic GATE frames: birth months, sock colours, same remainder mod m, equal subset sums.
- Always name the pigeons and the holes explicitly before computing.
Worked example
Problem. How many students must be in a class to guarantee at least 3 share a birth month?
Solution. Worst case 2 per month × 12 = 24, plus 1 → 25.
Inclusion–exclusion
- Two sets: |A∪B| = |A|+|B|−|A∩B|. Three sets: add singles, subtract pairs, add triple.
- “None of the properties”: |Ā1∩…∩Āk| = |U| − Σ|Ai| + Σ|Ai∩Aj| − …
- Surjections from n-set onto k-set: Σ_{i=0}^{k} (−1)^i C(k,i) (k−i)^n (= k! S(n,k)).
- Derangements !n = n! Σ_{i=0}^{n} (−1)^i / i! ≈ n!/e (nearest integer for many GATE NATs).
Formulas to remember
-
|A∪B∪C| = |A|+|B|+|C| − |A∩B| − |B∩C| − |C∩A| + |A∩B∩C| -
Surjections n→k: Σ (−1)^i C(k,i) (k−i)^n -
!n = n! Σ_{i=0}^{n} (−1)^i / i!
Worked example
Problem. Number of surjective functions from a 4-element set to a 2-element set?
Solution. C(2,0)2^4 − C(2,1)1^4 + C(2,2)0^4 = 16 − 2 + 0 = 14. (Or 2! S(4,2) = 2×7 = 14.)
Recurrence relations
- Define a_n in one sentence from the combinatorial story, then write the equation.
- Linear homogeneous order 2: a_n = p a_{n−1} + q a_{n−2} → characteristic r² − p r − q = 0.
- Distinct roots r1, r2 ⇒ a_n = A r1^n + B r2^n; fit A,B from initials.
- Common GATE stories: tilings (1×n with 1×1 and 1×2), binary strings with forbidden patterns, parenthesizations (Catalan — light touch).
Formulas to remember
-
Char. eq. for a_n − p a_{n−1} − q a_{n−2} = 0: r² − p r − q = 0 -
Fibonacci-like: F_n = F_{n−1} + F_{n−2}
Worked example
Problem. Number of binary strings of length n with no two consecutive 1s.
Solution. a_n = a_{n−1} + a_{n−2} (end with 0 → a_{n−1}; end with 01 → a_{n−2}), with a_1=2, a_2=3.
Counting functions & distributions
- Total functions A→B with |A|=n, |B|=k: k^n.
- Injections (n≤k): P(k,n). Bijections (n=k): n!.
- Onto = surjections via IE. Onto + ordered codomain labels ≠ unordered partitions.
- Distributing n distinct objects into k distinct boxes with none empty = surjections; identical objects need stars-and-bars variants.
Exam tips
- Underline whether order matters before writing P or C.
- For IE, write the universe size first, then subtract, then add intersections back.
- Recurrences: define a_n in words in one sentence before writing the equation.
- For derangements, compute the alternating sum carefully — sign errors are common in NAT.
- Pigeonhole “guarantee” questions use the worst-case +1 pattern: k(r−1)+1.
10 GATE-style MCQs for Combinatorics with full explanations. Attempt each question before revealing the answer.
The number of different n × n symmetric matrices with each element being either 0 or 1 is:
Show answer & explanation
Answer: C
A symmetric matrix is determined by the diagonal (n entries) and the strict upper triangle (C(n,2) = n(n−1)/2 entries). Total free bits = n + n(n−1)/2 = n(n+1)/2. Each is 0/1 ⇒ 2^{n(n+1)/2}.
How many onto (surjective) functions are there from a set with 5 elements to a set with 3 elements?
Show answer & explanation
Answer: A
Surjections = Σ (−1)^i C(3,i) (3−i)^5 = C(3,0)3^5 − C(3,1)2^5 + C(3,2)1^5 − C(3,3)0^5 = 243 − 96 + 3 − 0 = 150. (Also 3! S(5,3) = 6×25 = 150.)
The number of binary strings of length 10 with exactly three 1s is:
Show answer & explanation
Answer: C
Choose 3 positions out of 10 for the 1s (rest 0s). Order among chosen positions does not create new strings → C(10,3) = 120.
Number of derangements of 4 objects (!4) is:
Show answer & explanation
Answer: A
!4 = 4!(1 − 1 + 1/2 − 1/6 + 1/24) = 24(0.375) = 9.
In how many ways can 7 identical apples be distributed among 3 distinct children so that each child gets at least one apple?
Show answer & explanation
Answer: B
Identical apples, distinct children, ≥1 each: positive solutions to x+y+z=7 → C(6,2) = 15.
What is the smallest number of students in a class to ensure that at least 4 were born in the same month?
Show answer & explanation
Answer: B
Pigeonhole guarantee: 12×3 + 1 = 37.
The number of ways to arrange 5 distinct books on a circular shelf is:
Show answer & explanation
Answer: B
Circular arrangements of n distinct objects: (n−1)! = 4! = 24 (rotations identified).
Using inclusion–exclusion, |A∪B∪C| when |A|=|B|=|C|=20, each pairwise intersection has 8 elements, and |A∩B∩C|=3, equals:
Show answer & explanation
Answer: A
|A∪B∪C| = 3×20 − 3×8 + 3 = 60 − 24 + 3 = 39.
The recurrence a_n = a_{n−1} + 2 a_{n−2} with a_0=1, a_1=1 has closed form roots from which characteristic equation?
Show answer & explanation
Answer: A
Rewrite a_n − a_{n−1} − 2a_{n−2}=0 → r² − r − 2 = 0 → (r−2)(r+1)=0.
Number of functions from a set of 4 elements to a set of 3 elements that are NOT onto is:
Show answer & explanation
Answer: D
Total functions = 3^4 = 81. Surjections 4→3 = 3! S(4,3) = 6×6 = 36. Not onto = 81 − 36 = 45. Option D is 81−36.
Extra page-specific practice beyond the GATE samples. Attempt all 10, then reveal answers to check your reasoning.
Number of distinct permutations of the letters of the word GATECSE is:
Show answer & explanation
Answer: B) 7!/2!
GATECSE has 7 letters with E repeated twice and all other letters unique → 7!/2! = 2520.
How many 4-letter words (repeats allowed) can be formed from {A,B,C,D,E}?
Show answer & explanation
Answer: C) 5^4
Each of 4 positions has 5 choices independent of others → 5^4 = 625.
Number of ways to choose 3 distinct integers from 1…10 so that no two are consecutive?
Show answer & explanation
Answer: B) C(8,3)
Map x1<x2<x3 with gaps: let y1=x1, y2=x2−1, y3=x3−2 → 1≤y1<y2<y3≤8 → C(8,3).
A bag has 5 red and 7 blue identical-within-colour balls. Ways to choose 4 balls is:
Show answer & explanation
Answer: C) Number of (r,b) with r+b=4, 0≤r≤5, 0≤b≤7
Balls of same colour identical ⇒ outcomes are counts (r,b). Possible r=0..4 → 5 ways (all feasible). Not C(12,4) which assumes distinct balls.
!5 (derangements of 5 objects) equals:
Show answer & explanation
Answer: A) 44
!5 = 120(1−1+1/2−1/6+1/24−1/120) = 120(0.5−0.1667+0.04167−0.00833) = 120(0.36667) = 44.
Solve a_n = 5a_{n−1} − 6a_{n−2} with a_0=1, a_1=4. Then a_2 equals:
Show answer & explanation
Answer: B) 14
a_2 = 5a_1 − 6a_0 = 5·4 − 6·1 = 20−6 = 14. (Closed form: a_n = −2·2^n + 3·3^n also gives 14.)
Number of injective functions from a 3-set to a 5-set is:
Show answer & explanation
Answer: C) P(5,3)
Injections: P(5,3) = 5×4×3 = 60.
Positive integer solutions of x+y+z+w=10 is:
Show answer & explanation
Answer: B) C(9,3)
xi≥1: set zi=xi−1≥0 → z-sum=6 with 4 variables → C(6+4−1,3)=C(9,3)=84.
In a group of 50 people, must at least two share the same birth-week-of-year residue mod 7 (Sun…Sat pattern ignoring date)? More precisely: to guarantee two have birthday on the same weekday, minimum n is:
Show answer & explanation
Answer: B) 8
7 weekdays as holes → 7+1=8 guarantees two on the same weekday.
Number of binary strings of length 5 with no two consecutive 1s is:
Show answer & explanation
Answer: B) 13
a_n=a_{n−1}+a_{n−2}; a_1=2 (0,1), a_2=3 (00,01,10) → a_3=5, a_4=8, a_5=13.
Topic FAQs
When do I use combinations with repetition?
When choosing r items from n types where order does not matter and repeats are allowed — stars and bars / C(n+r−1, r).
Are generating functions required for GATE CSE?
Occasionally at a light level, but priority is P/C, pigeonhole, IE, and linear recurrences.
How do I remember derangement !n?
Use !n = n! Σ (−1)^i/i! from i=0 to n, or the recurrence !n = (n−1)[!(n−1)+!(n−2)]. For quick NAT, n!/e rounded to nearest integer often works for small n after you verify.
Hover a card to reveal the answer with a 3D flip. On touch devices, tap the card or use Show answer.