Skip to main content

Engineering Mathematics

Combinatorics

Build counting templates so permutations, combinations, and inclusion–exclusion become pattern recognition — then lock marks with GATE-style NATs and MCQs.

~8 hrs Frequent NAT source 10 samples · 10 practice · 10 cards

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! …)
SituationUseFormula cue
Ordered selection, no repeatPermutationP(n,r)
Unordered selection, no repeatCombinationC(n,r)
Ordered, repeats allowedWords / functionsn^r
Unordered, repeats allowedStars and barsC(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.
Exam pattern · 10 questions

GATE sample questions & answers

10 GATE-style MCQs for Combinatorics with full explanations. Attempt each question before revealing the answer.

Q1 GATE CS classic — symmetric 0-1 matrices

The number of different n × n symmetric matrices with each element being either 0 or 1 is:

  • A) 2^n
  • B) 2^{n²}
  • C) 2^{n(n+1)/2}
  • D) 2^{n(n−1)/2}
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}.

Q2 GATE-style surjection count

How many onto (surjective) functions are there from a set with 5 elements to a set with 3 elements?

  • A) 150
  • B) 243
  • C) 90
  • D) 120
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.)

Q3 Direct combination count

The number of binary strings of length 10 with exactly three 1s is:

  • A) 10³
  • B) P(10,3)
  • C) C(10,3)
  • D) 2³
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.

Q4 Derangement NAT/MCQ staple

Number of derangements of 4 objects (!4) is:

  • A) 9
  • B) 14
  • C) 15
  • D) 24
Show answer & explanation

Answer: A

!4 = 4!(1 − 1 + 1/2 − 1/6 + 1/24) = 24(0.375) = 9.

Q5 Stars and bars with lower bounds

In how many ways can 7 identical apples be distributed among 3 distinct children so that each child gets at least one apple?

  • A) C(7,3)
  • B) C(6,2)
  • C) 3^7
  • D) P(7,3)
Show answer & explanation

Answer: B

Identical apples, distinct children, ≥1 each: positive solutions to x+y+z=7 → C(6,2) = 15.

Q6 Generalized pigeonhole

What is the smallest number of students in a class to ensure that at least 4 were born in the same month?

  • A) 36
  • B) 37
  • C) 48
  • D) 49
Show answer & explanation

Answer: B

Pigeonhole guarantee: 12×3 + 1 = 37.

Q7 Circular permutations

The number of ways to arrange 5 distinct books on a circular shelf is:

  • A) 5!
  • B) 4!
  • C) 5!/2
  • D) C(5,1)
Show answer & explanation

Answer: B

Circular arrangements of n distinct objects: (n−1)! = 4! = 24 (rotations identified).

Q8 Three-set IE numerical

Using inclusion–exclusion, |A∪B∪C| when |A|=|B|=|C|=20, each pairwise intersection has 8 elements, and |A∩B∩C|=3, equals:

  • A) 39
  • B) 45
  • C) 48
  • D) 60
Show answer & explanation

Answer: A

|A∪B∪C| = 3×20 − 3×8 + 3 = 60 − 24 + 3 = 39.

Q9 Recurrence characteristic equation

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?

  • A) r² − r − 2 = 0
  • B) r² + r + 2 = 0
  • C) r² − 2r − 1 = 0
  • D) r² − r + 2 = 0
Show answer & explanation

Answer: A

Rewrite a_n − a_{n−1} − 2a_{n−2}=0 → r² − r − 2 = 0 → (r−2)(r+1)=0.

Q10 Total minus surjections

Number of functions from a set of 4 elements to a set of 3 elements that are NOT onto is:

  • A) 3^4 − 150
  • B) 3^4 − 36
  • C) 3^4 − 81
  • D) 81 − 36
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.

Topic drill · 10 questions

10 practice questions — Combinatorics

Extra page-specific practice beyond the GATE samples. Attempt all 10, then reveal answers to check your reasoning.

P1

Number of distinct permutations of the letters of the word GATECSE is:

  • A) 7!
  • B) 7!/2!
  • C) 7!/(2!2!)
  • D) 7!/3!
Show answer & explanation

Answer: B) 7!/2!

GATECSE has 7 letters with E repeated twice and all other letters unique → 7!/2! = 2520.

P2

How many 4-letter words (repeats allowed) can be formed from {A,B,C,D,E}?

  • A) P(5,4)
  • B) C(5,4)
  • C) 5^4
  • D) 4^5
Show answer & explanation

Answer: C) 5^4

Each of 4 positions has 5 choices independent of others → 5^4 = 625.

P3

Number of ways to choose 3 distinct integers from 1…10 so that no two are consecutive?

  • A) C(10,3)
  • B) C(8,3)
  • C) C(7,3)
  • D) P(8,3)
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).

P4

A bag has 5 red and 7 blue identical-within-colour balls. Ways to choose 4 balls is:

  • A) C(12,4)
  • B) 5×7
  • C) Number of (r,b) with r+b=4, 0≤r≤5, 0≤b≤7
  • D) 4!
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.

P5

!5 (derangements of 5 objects) equals:

  • A) 44
  • B) 45
  • C) 76
  • D) 120
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.

P6

Solve a_n = 5a_{n−1} − 6a_{n−2} with a_0=1, a_1=4. Then a_2 equals:

  • A) 10
  • B) 14
  • C) 16
  • D) 20
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.)

P7

Number of injective functions from a 3-set to a 5-set is:

  • A) 5^3
  • B) C(5,3)
  • C) P(5,3)
  • D) 3^5
Show answer & explanation

Answer: C) P(5,3)

Injections: P(5,3) = 5×4×3 = 60.

P8

Positive integer solutions of x+y+z+w=10 is:

  • A) C(10,4)
  • B) C(9,3)
  • C) C(13,3)
  • D) 10^4
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.

P9

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:

  • A) 7
  • B) 8
  • C) 14
  • D) 50
Show answer & explanation

Answer: B) 8

7 weekdays as holes → 7+1=8 guarantees two on the same weekday.

P10

Number of binary strings of length 5 with no two consecutive 1s is:

  • A) 8
  • B) 13
  • C) 16
  • D) 21
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.

Quick revision · 10 cards

10 flashcards — Combinatorics

Hover a card to reveal the answer with a 3D flip. On touch devices, tap the card or use Show answer.

Q1 When should you use P(n,r) instead of C(n,r) in a GATE counting problem?
Q2 What is the formula for combinations with repetition (stars and bars)?
Q3 How many distinct circular arrangements are there of n distinct objects?
Q4 Using the pigeonhole principle, how many pigeons guarantee at least r in one of k holes?
Q5 Write the two-set inclusion–exclusion formula for |A ∪ B|.
Q6 How many surjective functions are there from an n-element set onto a k-element set?
Q7 What is the formula for the number of derangements !n of n objects?
Q8 How many total, injective, and bijective functions are there from an n-set to a k-set?
Q9 What recurrence counts binary strings of length n with no two consecutive 1s?
Q10 How do you solve the recurrence a_n = 5a_{n−1} − 6a_{n−2}?