Unit 2 of 4 · M.Sc IT Sem 3

Unit 2: Combinatorics

Discrete Structures & Optimization notes · PTU syllabus (PGCA1917)

3 min read7 topics10 exam questions
On this page
  1. Unit summary
  2. Basic counting principles
  3. Permutations and combinations
  4. The inclusion–exclusion principle
  5. Recurrence relations
  6. Solving linear recurrence relations
  7. Generating functions
  8. The pigeonhole principle
  9. Key terms
  10. Quick revision
  11. Important questions

Unit summary

Counting underlies probability, algorithm analysis and cryptography. This unit covers the basic counting principles, permutations and combinations, the inclusion–exclusion principle, recurrence relations, generating functions and the pigeonhole principle with applications.

After this unit you can

  • Apply the sum and product rules
  • Compute permutations and combinations
  • Use inclusion–exclusion and the pigeonhole principle
  • Solve recurrence relations and use generating functions

PTU syllabus topics

  • Basic counting principles
  • permutations and combinations
  • inclusion-exclusion principle
  • recurrence relations
  • generating functions
  • pigeonhole principle and applications
Key formulasCounting principles
  • Permutations

    nPr = n! / (n − r)!

  • Combinations

    nCr = n! / [r! (n − r)!]

  • Inclusion-exclusion

    n(A ∪ B ∪ C) = Σ n(A) − Σ n(A ∩ B) + n(A ∩ B ∩ C)

  • Pigeonhole principle

    n + 1 items in n boxes: some box has two or more

1

Topic 1

Basic counting principles

ComparisonSum and product rules
Rule
Example

Sum rule

If a task can be done in one of m ways or one of n other ways (no overlap), there are m + n ways

Choose one elective from 5 IT or 3 management electives: 8 ways

Product rule

If a task has two stages with m and n ways, there are m × n ways

A password of 2 letters then 3 digits: 26² × 10³ = 6,76,000

2

Topic 2

Permutations and combinations

Key formulasCounting formulas
  • Permutations of n distinct objects taken r

    P(n, r) = n! ÷ (n − r)!

  • Combinations

    C(n, r) = n! ÷ (r! (n − r)!)

  • Permutations with repetition allowed

    nʳ

  • Permutations of a multiset

    n! ÷ (n1! n2! … nk!)

  • Combinations with repetition

    C(n + r − 1, r)

  • Circular permutations

    (n − 1)!

Example

Ways to choose a captain and vice-captain from 11: P(11, 2) = 110. Ways to choose a 3-member committee from 10: C(10, 3) = 120. Arrangements of MISSISSIPPI: 11! ÷ (4! 4! 2!) = 34,650.

  • Pascal's identity: C(n, r) = C(n − 1, r − 1) + C(n − 1, r); binomial theorem: (x + y)ⁿ = Σ C(n, r) xⁿ⁻ʳ yʳ.
3

Topic 3

The inclusion–exclusion principle

Key formulasInclusion–exclusion
  • Two sets

    n(A ∪ B) = n(A) + n(B) − n(A ∩ B)

  • Three sets

    n(A ∪ B ∪ C) = n(A) + n(B) + n(C) − n(A ∩ B) − n(A ∩ C) − n(B ∩ C) + n(A ∩ B ∩ C)

Example

Integers from 1 to 100 divisible by 2, 3 or 5: 50 + 33 + 20 − 16 − 10 − 6 + 3 = 74.

  • Derangements: permutations with no element in its original place: Dn = n! (1 − 1/1! + 1/2! − … + (−1)ⁿ/n!); D4 = 9.
4

Topic 4

Recurrence relations

  • Recurrence relation: an equation defining each term of a sequence using earlier terms, with initial conditions.
ClassificationCommon recurrences
Recurrences
  • Linear homogeneous with constant coefficients

    an = c1 an−1 + c2 an−2

  • Arithmetic

    an = an−1 + d gives an = a0 + nd

  • Geometric

    an = r an−1 gives an = a0 rⁿ

  • Tower of Hanoi

    Hn = 2Hn−1 + 1, H1 = 1, giving Hn = 2ⁿ − 1

  • Divide and conquer

    T(n) = 2T(n/2) + n gives O(n log n)

  • Solving linear homogeneous recurrences: form the characteristic equation r² − c1 r − c2 = 0; distinct roots r1, r2 give an = A r1ⁿ + B r2ⁿ; repeated root r gives an = (A + Bn) rⁿ; use initial conditions to find A and B.

Example

an = 5an−1 − 6an−2, a0 = 1, a1 = 4: r² − 5r + 6 = 0, r = 2, 3; an = A·2ⁿ + B·3ⁿ; A + B = 1, 2A + 3B = 4 → B = 2, A = −1; an = 2·3ⁿ − 2ⁿ.

5

Topic 5

Solving linear recurrence relations

ProcessSolving a homogeneous linear recurrence
  1. 1Write the characteristic equation (aₙ = c1 aₙ₋₁ + c2 aₙ₋₂ gives r² − c1 r − c2 = 0)
  2. 2Find the roots
  3. 3Distinct roots r1, r2: aₙ = A r1ⁿ + B r2ⁿ
  4. 4Repeated root r: aₙ = (A + Bn) rⁿ
  5. 5Use initial conditions to find A and B

Example

aₙ = 5aₙ₋₁ − 6aₙ₋₂, a0 = 1, a1 = 4. r² − 5r + 6 = 0 → r = 2, 3. aₙ = A·2ⁿ + B·3ⁿ; A + B = 1, 2A + 3B = 4 → B = 2, A = −1. So aₙ = 2·3ⁿ − 2ⁿ.

  • Algorithm analysis: T(n) = 2T(n/2) + n (merge sort) gives O(n log n); T(n) = T(n − 1) + 1 gives O(n).
6

Topic 6

Generating functions

  • The generating function of a sequence a0, a1, a2, … is G(x) = a0 + a1x + a2x² + … — a power series used to count and to solve recurrences.
Key formulasUseful generating functions
  • 1, 1, 1, …

    1 ÷ (1 − x)

  • 1, a, a², …

    1 ÷ (1 − ax)

  • C(n, 0), C(n, 1), …, C(n, n)

    (1 + x)ⁿ

  • 1, 2, 3, 4, …

    1 ÷ (1 − x)²

Example

Ways to pick 4 fruits from apples, bananas and oranges with unlimited supply: coefficient of x⁴ in 1 ÷ (1 − x)³ = C(4 + 2, 2) = 15.

7

Topic 7

The pigeonhole principle

  • If n + 1 or more objects are put into n boxes, at least one box holds two or more. Generalised: if N objects go into k boxes, some box holds at least ceil(N ÷ k).

Example

Among 367 people two share a birthday. In a class of 50, at least ceil(50 ÷ 12) = 5 students were born in the same month. Any 5 points in a unit square include two within distance √2 ÷ 2.

  • Applications: collisions in hashing, lossless compression limits (no algorithm can shorten every file), scheduling and proofs of existence.

Key terms

Permutation
Ordered arrangement of objects
Combination
Unordered selection of objects
Inclusion–exclusion
Counting a union by adding and subtracting intersections
Recurrence relation
Equation defining a term from earlier terms
Pigeonhole principle
More objects than boxes forces a shared box

Quick revision

  • Sum and product rules.
  • P(n, r), C(n, r), repetition, multisets, circular; Pascal; binomial theorem.
  • Inclusion–exclusion for two and three sets; derangements.
  • Linear recurrences: characteristic equation; divide-and-conquer recurrences.
  • Generating functions; pigeonhole and generalised pigeonhole principles.

Important exam questions

Practice questions written to the PTU exam pattern for this unit's syllabus: short answers (Section A style) and long answers (Sections B and C style).

Short-answer questions

  1. Q1.How many 4-digit PINs are possible?
  2. Q2.Find C(8, 3) and P(8, 3).
  3. Q3.How many integers from 1 to 60 are divisible by 2 or 3?
  4. Q4.Solve aₙ = 3aₙ₋₁, a0 = 2.
  5. Q5.What is the generating function of 1, 1, 1, …?
  6. Q6.Show that among 13 people two share a birth month.

Long-answer questions

  1. Q1.Explain permutations and combinations with examples.
  2. Q2.Explain and apply the inclusion–exclusion principle.
  3. Q3.Solve linear recurrence relations with the characteristic equation.
  4. Q4.Explain generating functions and the pigeonhole principle with applications.

Stuck on this unit?

Message SBS on WhatsApp for help with Discrete Structures & Optimization, or to ask about studying M.Sc IT at Synetic.

WhatsApp us