Background pattern

Volume 1

Discrete Mathematics: Combinatory

Study Notes

Concept reference & formula sheet for this chapter

Syllabus: Combinatorics: Counting, Recurrence relations, Generating functions.

Mark Distribution in Previous GATE

Welcome to the "Discrete Mathematics: Combinatory" chapter! This section is a cornerstone of computer science, providing the fundamental tools to count, arrange, and select objects, analyze algorithms, and understand probability. For the GATE Computer Science exam, combinatorics is crucial for topics like algorithm analysis (counting operations, permutations), data structures (hashing, tree traversals), probability, and even network protocols. Typically, you can expect 3-5 marks from this area, often in conjunction with probability or algorithm analysis. Questions range from direct application of formulas to more complex problem-solving scenarios requiring a combination of principles, sometimes involving tricky wording or subtle conditions like 'distinct' vs. 'identical' items, or 'empty' vs. 'non-empty' containers.

Topic-wise Key Concepts

Balls In Bins

Definition and Core Idea: The "Balls In Bins" paradigm is a versatile model for various counting problems. It involves distributing a certain number of "balls" (items) into a certain number of "bins" (containers or categories), considering whether the balls are identical or distinct, and whether the bins are identical or distinct, and if bins can be empty or must contain at least one ball.

Important Formulas, Theorems, and Results:

1. Distinct Balls into Distinct Bins

  • Any number of balls per bin: If there are nn distinct balls and kk distinct bins, each ball can go into any of the kk bins. Total ways: knk^n.

  • At most one ball per bin (injective mapping): This is equivalent to permutations. Total ways: P(k,n)=k!(k−n)!P(k, n) = \frac{k!}{(k-n)!} if k≥nk \ge n, and 0 otherwise.

2. Identical Balls into Distinct Bins

  • Any number of balls per bin (stars and bars): If there are nn identical balls and kk distinct bins, this is equivalent to finding non-negative integer solutions to x1+x2+⋯+xk=nx_1 + x_2 + \dots + x_k = n. Total ways: C(n+k−1,k−1)=C(n+k−1,n)C(n + k - 1, k - 1) = C(n + k - 1, n).

  • At least one ball per bin (stars and bars with pre-allocation): First, place one ball in each bin, leaving n−kn - k balls to distribute. Total ways: C((n−k)+k−1,k−1)=C(n−1,k−1)C((n - k) + k - 1, k - 1) = C(n - 1, k - 1) if n≥kn \ge k, and 0 otherwise.

  1. Distinct Balls into Identical Bins: This is related to Stirling Numbers of the Second Kind .
  • Any number of balls per bin: Sum of Stirling numbers of the second kind. Total ways: ∑i=1kS(n,i)\sum_{i=1}^k S(n, i).

  • At least one ball per bin: Total ways: S(n,k)S(n, k).

S(n,k)=1k!∑j=0k(−1)jC(k,j)(k−j)nS(n, k) = \frac{1}{k!} \sum_{j=0}^k (-1)^j C(k, j)(k - j)^n

  1. Identical Balls into Identical Bins: This is related to integer partitions.
  • Any number of balls per bin: The number of partitions of nn into at most kk parts, denoted P(n,k)P(n, k).

  • At least one ball per bin: The number of partitions of nn into exactly kk parts, denoted Pk(n)P_k(n). There is no simple closed-form formula; often solved using generating functions or recursion.

Key Properties and Identities:

  • The "stars and bars" formula C(n+k−1,k−1)C(n + k - 1, k - 1) is fundamental for problems involving distributing identical items into distinct categories or finding non-negative integer solutions.

  • Understanding the distinction between "distinct" and "identical" for both balls and bins is paramount.

Common Pitfalls or Tricky Points:

  • Confusing Identical vs. Distinct: This is the most common error. Always identify if the items being distributed and the containers are distinguishable or not.

  • Empty vs. Non-empty Bins: Pay close attention to whether bins are allowed to be empty or if they must contain at least one item. This changes the formula significantly.

  • Overlapping Cases: Ensure that cases are mutually exclusive and exhaustive when breaking down a problem.

Standard Problem-Solving Techniques or Shortcuts:

  • Mapping to Stars and Bars: Many problems can be rephrased as distributing identical items into distinct bins. For example, finding the number of non-negative integer solutions to an equation.

  • Inclusion-Exclusion Principle: For problems where "at least one" condition is difficult to apply directly, use inclusion-exclusion to subtract cases where bins are empty.

  • Complementary Counting: Sometimes it's easier to count the total ways and subtract the "unwanted" ways.

Combinatory

Definition and Core Idea: Combinatorics is the branch of discrete mathematics concerned with counting, arrangement, and selection of objects. It deals with permutations (arrangements where order matters) and combinations (selections where order does not matter), often involving constraints or repetitions.

Important Formulas, Theorems, and Results:

1. Permutations (Order Matters)

  • Permutations of nn distinct items taken kk at a time: P(n,k)=n!(n−k)!P(n, k) = \frac{n!}{(n-k)!}.

  • Permutations of nn distinct items taken nn at a time: P(n,n)=n!P(n, n) = n!.

  • Permutations with Repetition (multiset permutations): For nn items where there are n1n_1 identical items of type 1, n2n_2 of type 2, ..., nkn_k of type kk, and n1+n2+⋯+nk=nn_1 + n_2 + \dots + n_k = n. Total ways: n!n1!n2!…nk!\frac{n!}{n_1!n_2!\dots n_k!}.

  • Circular Permutations: For nn distinct items arranged in a circle, total ways: (n−1)!(n - 1)!. If arrangements are symmetric (e.g., beads on a necklace), divide by 2: (n−1)!2\frac{(n-1)!}{2}.

2. Combinations (Order Does Not Matter)

  • Combinations of nn distinct items taken kk at a time: C(n,k)=(nk)=n!k!(n−k)!C(n, k) = \binom{n}{k} = \frac{n!}{k!(n-k)!}.

  • Combinations with Repetition (multiset combinations): Selecting kk items from nn types with repetition allowed. Total ways: C(n+k−1,k)C(n + k - 1, k). This is equivalent to the "identical balls into distinct bins" problem.

3. Binomial Theorem

(x+y)n=∑k=0n(nk)xn−kyk(x + y)^n = \sum_{k=0}^n \binom{n}{k} x^{n-k} y^k

4. Multinomial Theorem

(x1+x2+⋯+xm)n=∑n1+⋯+nm=nn!n1!n2!…nm!x1n1x2n2…xmnm(x_1 + x_2 + \dots + x_m)^n = \sum_{n_1 + \dots + n_m = n} \frac{n!}{n_1!n_2!\dots n_m!} x_1^{n_1} x_2^{n_2} \dots x_m^{n_m}

Key Properties and Identities:

  • Symmetry Identity: C(n,k)=C(n,n−k)C(n, k) = C(n, n - k).

  • Pascal's Identity: C(n,k)=C(n−1,k)+C(n−1,k−1)C(n, k) = C(n - 1, k) + C(n - 1, k - 1).

  • Sum of Binomial Coefficients: ∑k=0nC(n,k)=2n\sum_{k=0}^n C(n, k) = 2^n.

  • Hockey-stick Identity: ∑i=rnC(i,r)=C(n+1,r+1)\sum_{i=r}^n C(i, r) = C(n + 1, r + 1).

Common Pitfalls or Tricky Points:

  • Overcounting/Undercounting: Ensure each valid arrangement/selection is counted exactly once. This often happens when dealing with symmetry or identical items.

  • "At Least" / "At Most" Conditions: These often require complementary counting or casework.

  • Distinguishing Permutations vs. Combinations: If the order of selection or arrangement matters, it's a permutation. If not, it's a combination.

Standard Problem-Solving Techniques or Shortcuts:

  • Principle of Multiplication: If a task can be broken into a sequence of kk independent steps, and step ii can be performed in nin_i ways, then the total number of ways is n1×n2×⋯×nkn_1 \times n_2 \times \cdots \times n_k.
  • Principle of Addition: If a task can be performed in one of kk mutually exclusive ways, and way ii can be performed in nin_i ways, then the total number of ways is n1+n2+⋯+nkn_1 + n_2 + \cdots + n_k.
  • Complementary Counting: Count the total number of ways and subtract the number of "unwanted" ways. Useful for "at least one" type problems.
  • Casework: Break down a complex problem into simpler, mutually exclusive cases and sum the results.

Counting

Definition and Core Idea: Counting, in a broader sense, encompasses the fundamental principles used to determine the size of finite sets. It builds upon combinatorial concepts and introduces powerful tools like the Principle of Inclusion-Exclusion to handle complex scenarios involving overlapping sets.

Important Formulas, Theorems, and Results:

1. Principle of Inclusion-Exclusion (PIE)

  • For two sets: ∣A∪B∣=∣A∣+∣B∣−∣A∩B∣|A \cup B| = |A| + |B| - |A \cap B|.
  • For three sets: ∣A∪B∪C∣=∣A∣+∣B∣+∣C∣−(∣A∩B∣+∣A∩C∣+∣B∩C∣)+∣A∩B∩C∣|A \cup B \cup C| = |A| + |B| + |C| - (|A \cap B| + |A \cap C| + |B \cap C|) + |A \cap B \cap C|.
  • General form for nn sets: [ \left| \bigcup_{i=1}^n A_i \right| = \sum_{i} |A_i| - \sum_{i
  1. Derangements: A permutation of nn objects such that no object remains in its original position. The number of derangements of nn objects, denoted DnD_n or !n!n:

Dn=n!∑k=0n(−1)kk!=n!(10!−11!+12!−⋯+(−1)nn!)D_n = n! \sum_{k=0}^n \frac{(-1)^k}{k!} = n! \left( \frac{1}{0!} - \frac{1}{1!} + \frac{1}{2!} - \cdots + \frac{(-1)^n}{n!} \right)

For large nn, Dn≈n!eD_n \approx \frac{n!}{e}.

Key Properties and Identities:

  • PIE is essential for counting elements in the union of non-disjoint sets.
  • Derangements are a specific application of PIE for permutations with no fixed points.

Common Pitfalls or Tricky Points:

  • Incorrectly Identifying Sets for PIE: Clearly define the properties that form the sets A,B,C,…A, B, C, \dots and their intersections.
  • Misapplying PIE: Ensure you are alternating signs correctly and covering all necessary intersections.
  • "At Least One" vs. "Exactly One": PIE typically helps with "at least one" conditions. For "exactly one," you might need to combine PIE with complementary counting or other techniques.

Standard Problem-Solving Techniques or Shortcuts:

  • Casework: Break down complex problems into simpler, mutually exclusive scenarios.
  • Complementary Counting: Count the total possibilities and subtract the undesirable ones. Often used in conjunction with PIE.
  • Direct Application of PIE: For problems involving properties that overlap, PIE is usually the most direct approach.

Generating Functions

Definition and Core Idea: A generating function is a formal power series where the coefficients represent the terms of a sequence. It provides a powerful algebraic tool for solving recurrence relations, counting problems, and proving combinatorial identities by converting sequence operations into algebraic manipulations.

Important Formulas, Theorems, and Results:

    1. Definition: For a sequence a0,a1,a2,…a_0, a_1, a_2, \dots, its ordinary generating function (OGF) is G(x)=∑n=0∞anxnG(x) = \sum_{n=0}^{\infty} a_n x^n.
    1. Common Generating Functions:
  • Constant sequence 1,1,1,…1, 1, 1, …: G(x)=∑n=0∞xn=11−xG(x) = \sum_{n=0}^{\infty} x^n = \frac{1}{1-x}.

  • Arithmetic progression 1,a,a2,…1, a, a^2, …: G(x)=∑n=0∞(ax)n=11−axG(x) = \sum_{n=0}^{\infty} (ax)^n = \frac{1}{1-ax}.

  • Binomial coefficients C(n,k)C(n, k) for fixed nn: G(x)=∑k=0nC(n,k)xk=(1+x)nG(x) = \sum_{k=0}^n C(n, k)x^k = (1+x)^n.

  • Combinations with repetition C(n+k−1,k)C(n+k-1, k) for fixed nn: G(x)=∑k=0∞C(n+k−1,k)xk=1(1−x)nG(x) = \sum_{k=0}^{\infty} C(n+k-1, k)x^k = \frac{1}{(1-x)^n}.

  • Sequence an=na_n = n: G(x)=∑n=0∞nxn=x(1−x)2G(x) = \sum_{n=0}^{\infty} nx^n = \frac{x}{(1-x)^2}.

  • Sequence an=n2a_n = n^2: G(x)=∑n=0∞n2xn=x(1+x)(1−x)3G(x) = \sum_{n=0}^{\infty} n^2 x^n = \frac{x(1+x)}{(1-x)^3}.

3. Operations on Generating Functions

  • Addition : If A(x)=∑anxnA(x) = \sum a_n x^n and B(x)=∑bnxnB(x) = \sum b_n x^n, then A(x)+B(x)=∑(an+bn)xnA(x) + B(x) = \sum (a_n + b_n)x^n.

  • Multiplication (Convolution) : If A(x)=∑anxnA(x) = \sum a_n x^n and B(x)=∑bnxnB(x) = \sum b_n x^n, then A(x)B(x)=∑cnxnA(x)B(x) = \sum c_n x^n, where cn=∑k=0nakbn−kc_n = \sum_{k=0}^n a_k b_{n-k}. This is crucial for counting combinations of independent choices.

  • Differentiation : G′(x)=∑n=1∞nanxn−1G'(x) = \sum_{n=1}^{\infty} n a_n x^{n-1}. So, xG′(x)=∑n=1∞nanxnxG'(x) = \sum_{n=1}^{\infty} n a_n x^n.

  • Integration : ∫G(x)dx=∑n=0∞ann+1xn+1\int G(x)dx = \sum_{n=0}^{\infty} \frac{a_n}{n+1} x^{n+1}.

  • Shift : xkG(x)=∑n=0∞anxn+kx^k G(x) = \sum_{n=0}^{\infty} a_n x^{n+k} (shifts coefficients to the right). G(x)−a0−⋯−ak−1xk−1xk=∑n=k∞anxn−k\frac{G(x)-a_0-\cdots-a_{k-1}x^{k-1}}{x^k} = \sum_{n=k}^{\infty} a_n x^{n-k} (shifts coefficients to the left).

Key Properties and Identities:

  • The coefficient of xnx^n in a generating function G(x)G(x) is ana_n, denoted [xn]G(x)[x^n]G(x).

  • Generating functions are particularly useful for problems involving sums, combinations with repetition, and solving linear recurrence relations.

Common Pitfalls or Tricky Points:

  • Forming the Correct GF : Carefully translate the problem's constraints (e.g., minimum/maximum number of items, distinct/identical items) into the terms of the generating function.

  • Extracting Coefficients : This often requires partial fraction decomposition for rational functions or using generalized binomial theorem.

  • Confusion with Exponential Generating Functions (EGFs) : EGFs are used for permutations, while OGFs are for combinations. GATE typically focuses on OGFs.

Standard Problem-Solving Techniques or Shortcuts:

Solving Recurrence Relations :

    1. Write the recurrence relation.
    1. Multiply by xnx^n and sum over all valid nn.
    1. Manipulate the sums to relate them to the generating function G(x)G(x).
    1. Solve for G(x)G(x) as a rational function.
    1. Use partial fraction decomposition and known series expansions to find the coefficient of xnx^n.
  • Counting Combinations : Represent each type of item or choice as a factor in the generating function. The coefficient of xnx^n in the product of these factors gives the number of ways to choose nn items.

Modular Arithmetic

Definition and Core Idea : Modular arithmetic is a system of arithmetic for integers, where numbers "wrap around" when they reach a certain value—the modulus. It's fundamental in cryptography, number theory, and hashing, and is used in GATE for problems involving remainders, large powers, and divisibility.

Important Formulas, Theorems, and Results:

    1. Congruence Relation : a≡b(modm)a \equiv b \pmod{m} if mm divides (a−b)(a - b), or equivalently, aa and bb have the same remainder when divided by mm.

2. Basic Properties :

  • If a≡b(modm)a \equiv b \pmod{m} and c≡d(modm)c \equiv d \pmod{m}, then:

  • a+c≡b+d(modm)a + c \equiv b + d \pmod{m}

  • a−c≡b−d(modm)a - c \equiv b - d \pmod{m}

  • ac≡bd(modm)ac \equiv bd \pmod{m}

  • ak≡bk(modm)a^k \equiv b^k \pmod{m} for any positive integer kk.

    1. Modular Inverse: An integer a−1a^{-1} is the modular multiplicative inverse of aa modulo mm if aa−1≡1(modm)aa^{-1} \equiv 1 \pmod{m}.
  • An inverse exists if and only if gcd⁡(a,m)=1\gcd(a, m) = 1.

  • Can be found using the Extended Euclidean Algorithm.

    1. Euler's Totient Function ϕ(n)\phi(n): Counts the number of positive integers up to nn that are relatively prime to nn.
  • If n=p1k1p2k2…prkrn = p_1^{k_1} p_2^{k_2} \dots p_r^{k_r} (prime factorization), then ϕ(n)=n(1−1p1)(1−1p2)…(1−1pr)\phi(n) = n \left(1 - \frac{1}{p_1}\right) \left(1 - \frac{1}{p_2}\right) \dots \left(1 - \frac{1}{p_r}\right).

  • If pp is prime, ϕ(p)=p−1\phi(p) = p - 1.

  • If pp is prime, ϕ(pk)=pk−pk−1\phi(p^k) = p^k - p^{k-1}.

    1. Fermat's Little Theorem: If pp is a prime number, then for any integer aa not divisible by pp, ap−1≡1(modp)a^{p-1} \equiv 1 \pmod{p}. Also, ap≡a(modp)a^p \equiv a \pmod{p} for any integer aa.
    1. Euler's Theorem: If nn and aa are coprime positive integers, then aϕ(n)≡1(modn)a^{\phi(n)} \equiv 1 \pmod{n}. (Fermat's Little Theorem is a special case of Euler's Theorem when nn is prime).
    1. Chinese Remainder Theorem (CRT): (Conceptually important, full formula rarely needed for GATE) If integers n1,n2,…,nkn_1, n_2, \dots, n_k are pairwise coprime, then for any given integers a1,a2,…,aka_1, a_2, \dots, a_k, there exists an integer xx that solves the system of congruences:

x≡a1(modn1)x \equiv a_1 \pmod{n_1}

x≡a2(modn2)x \equiv a_2 \pmod{n_2}

⋮\vdots

x≡ak(modnk)x \equiv a_k \pmod{n_k}

Moreover, all solutions xx are congruent modulo N=n1n2…nkN = n_1 n_2 \dots n_k.

Key Properties and Identities:

  • Modular arithmetic allows us to work with remainders, simplifying calculations involving very large numbers.

  • The concept of modular inverse is critical for division in modular arithmetic (multiplication by inverse).

  • Fermat's Little Theorem and Euler's Theorem are powerful for simplifying large exponents modulo a number.

Common Pitfalls or Tricky Points:

  • Division: Division is not directly defined. Instead, multiply by the modular inverse. If the inverse doesn't exist (i.e., gcd⁡(a,m)≠1\gcd(a, m) \neq 1), division is not possible.

  • Negative Results: If a calculation yields a negative number, add the modulus until it's positive. E.g., −5≡2(mod7)-5 \equiv 2 \pmod{7}.

  • Large Exponents: Always reduce the exponent modulo ϕ(m)\phi(m) (if gcd⁡(a,m)=1\gcd(a, m) = 1) or modulo m−1m - 1 (if mm is prime and \\gcd(a, m) = 1$) to simplify calculations using Euler's or Fermat's theorem.

Standard Problem-Solving Techniques or Shortcuts:

  • Repeated Squaring (Exponentiation by Squaring): Efficiently compute ab(modm)a^b \pmod{m} by repeatedly squaring the base and reducing modulo mm. Example: ab=ab/2⋅ab/2a^b = a^{b/2} \cdot a^{b/2} if bb is even, ab=a⋅a(b−1)/2⋅a(b−1)/2a^b = a \cdot a^{(b-1)/2} \cdot a^{(b-1)/2} if bb is odd.

Finding Modular Inverse:

  • Extended Euclidean Algorithm: For ax+my=gcd⁡(a,m)ax + my = \gcd(a, m). If gcd⁡(a,m)=1\gcd(a, m) = 1, then ax≡1(modm)ax \equiv 1 \pmod{m}, so xx is the inverse.

  • Fermat's Little Theorem: If mm is prime, am−2≡a−1(modm)a^{m-2} \equiv a^{-1} \pmod{m}.

  • Euler's Theorem: If gcd⁡(a,m)=1\gcd(a, m) = 1, aϕ(m)−1≡a−1(modm)a^{\phi(m)-1} \equiv a^{-1} \pmod{m}.

  • Properties of Congruence: Apply addition, subtraction, multiplication properties to simplify expressions before taking the final modulo.

Pigeonhole Principle

Definition and Core Idea: The Pigeonhole Principle (PHP) is a fundamental concept stating that if nn items are put into

mm containers, with n>mn > m, then at least one container must contain more than one item. It's a simple yet powerful tool for proving existence in combinatorial problems.

Important Formulas, Theorems, and Results:

    1. Basic Pigeonhole Principle: If nn pigeons are placed into mm pigeonholes, and n>mn > m, then at least one pigeonhole contains more than one pigeon.
    1. Generalized Pigeonhole Principle: If nn pigeons are placed into mm pigeonholes, then at least one pigeonhole must contain at least ⌈n/m⌉⌈n/m⌉ pigeons.

Key Properties and Identities:

  • PHP is an existence principle; it tells you that something must happen, but not how to find it or how many times it happens.
  • It's often used in proofs to show that a certain condition must hold true.

Common Pitfalls or Tricky Points:

  • Identifying Pigeons and Pigeonholes: The most crucial step is correctly defining what constitutes a "pigeon" and a "pigeonhole" in the context of the problem. This often requires creative thinking.
  • Applying Generalized PHP: Ensure you correctly calculate ⌈n/m⌉⌈n/m⌉.
  • "At Least" vs. "Exactly": PHP guarantees "at least" a certain number; it doesn't guarantee "exactly."

Standard Problem-Solving Techniques or Shortcuts:

  • Creative Definitions: The key is to define pigeons and pigeonholes in a way that makes the principle applicable.
  • Pigeons are often the items being distributed or selected.
  • Pigeonholes are often categories, properties, or possible outcomes.
  • Proof by Contradiction: Sometimes, assuming the opposite of what you want to prove (i.e., no pigeonhole has more than kk pigeons) can lead to a contradiction using PHP.
  • Small Examples: Test with small numbers to understand the problem structure and how to define pigeons/pigeonholes.

Recurrence Relation

Definition and Core Idea: A recurrence relation is an equation that defines a sequence where each term is given as a function of its preceding terms. They are fundamental in algorithm analysis (e.g., complexity of recursive algorithms), combinatorics (e.g., Fibonacci numbers), and discrete probability.

Important Formulas, Theorems, and Results:

1. Linear Homogeneous Recurrence Relations with Constant Coefficients

an=c1an−1+c2an−2+⋯+ckan−ka_n = c_1 a_{n-1} + c_2 a_{n-2} + \dots + c_k a_{n-k}

  • Characteristic Equation: rk−c1rk−1−c2rk−2−⋯−ck=0r^k - c_1 r^{k-1} - c_2 r^{k-2} - \dots - c_k = 0.
  • Distinct Roots: If r1,r2,…,rkr_1, r_2, \dots, r_k are distinct roots, the general solution is an=A1r1n+A2r2n+⋯+Akrkna_n = A_1 r_1^n + A_2 r_2^n + \dots + A_k r_k^n.
  • Repeated Roots: If a root rr has multiplicity mm, its contribution to the general solution is (A1+A2n+⋯+Amnm−1)rn(A_1 + A_2 n + \dots + A_m n^{m-1})r^n.
  • The constants AiA_i are determined by the initial conditions.

2. Linear Non-Homogeneous Recurrence Relations

an=c1an−1+⋯+ckan−k+F(n)a_n = c_1 a_{n-1} + \dots + c_k a_{n-k} + F(n)

  • The general solution is an=an(h)+an(p)a_n = a_n^{(h)} + a_n^{(p)}, where an(h)a_n^{(h)} is the homogeneous solution and an(p)a_n^{(p)} is a particular solution.
  • Finding an(p)a_n^{(p)}: Guess a form for an(p)a_n^{(p)} based on F(n)F(n).
  • ▪ If F(n)F(n) is a polynomial of degree dd, guess P(n)=Cdnd+⋯+C0P(n) = C_d n^d + \dots + C_0. If 1 is a root of the characteristic equation with multiplicity ss, multiply by nsn^s.
  • ▪ If F(n)F(n) is an exponential C⋅bnC \cdot b^n, guess A⋅bnA \cdot b^n. If bb is a root of the characteristic equation with multiplicity ss,

multiply by nsn^s.

    1. Master Theorem (for Divide and Conquer Recurrences): For recurrences of the form T(n)=aT(n/b)+f(n)T(n) = aT(n/b) + f(n) where a≥1a \geq 1, b>1b > 1, and f(n)f(n) is asymptotically positive.
    1. If f(n)=O(nlog⁡ba−ϵ)f(n) = O(n^{\log_b a - \epsilon}) for some ϵ>0\epsilon > 0, then T(n)=Θ(nlog⁡ba)T(n) = \Theta(n^{\log_b a}).
    1. If f(n)=Θ(nlog⁡ba)f(n) = \Theta(n^{\log_b a}), then T(n)=Θ(nlog⁡balog⁡n)T(n) = \Theta(n^{\log_b a} \log n).
    1. If f(n)=Ω(nlog⁡ba+ϵ)f(n) = \Omega(n^{\log_b a + \epsilon}) for some ϵ>0\epsilon > 0, AND af(n/b)≤cf(n)af(n/b) \leq cf(n) for some c<1c < 1 and sufficiently large nn (regularity condition), then T(n)=Θ(f(n))T(n) = \Theta(f(n)).

Key Properties and Identities:

  • The order of a recurrence relation is the difference between the largest and smallest indices.
  • Linear recurrence relations with constant coefficients are solvable using the characteristic equation method.
  • The Master Theorem provides a quick way to find asymptotic bounds for many divide-and-conquer algorithms.

Common Pitfalls or Tricky Points:

  • Incorrect Characteristic Equation: Ensure all terms are on one side and coefficients are correct.
  • Handling Repeated Roots: Don't forget the n,n2,…n, n^2, \dots factors for repeated roots.
  • Finding Particular Solutions: The guess for an(p)a_n^{(p)} must be adjusted if it overlaps with the homogeneous solution.
  • Boundary Conditions: Always use initial conditions to find the constants AiA_i in the general solution.
  • Master Theorem Conditions: Carefully check all three cases and the regularity condition for case 3.

Standard Problem-Solving Techniques or Shortcuts:

  • Characteristic Equation Method: The standard approach for linear homogeneous recurrences.
  • Substitution Method: For simpler recurrences, guess a solution and prove it by induction.
  • Generating Functions: A powerful general method for solving linear recurrences (see Generating Functions section).
  • Master Theorem: For divide-and-conquer algorithms, this is the fastest way to find the asymptotic complexity.

Summation

Definition and Core Idea: Summation involves finding the sum of a sequence of numbers, often expressed using sigma notation. It's crucial for analyzing algorithm complexity, calculating probabilities, and working with series in various mathematical contexts.

Important Formulas, Theorems, and Results:

    1. Arithmetic Series: Sum of an arithmetic progression a,a+d,a+2d,…,a+(n−1)da, a + d, a + 2d, \dots, a + (n - 1)d.

∑i=0n−1(a+id)=n2(2a+(n−1)d)\sum_{i=0}^{n-1} (a + id) = \frac{n}{2}(2a + (n - 1)d)

If a=1,d=1a = 1, d = 1, sum of first nn integers: ∑i=1ni=n(n+1)2\sum_{i=1}^n i = \frac{n(n+1)}{2}.

    1. Geometric Series: Sum of a geometric progression a,ar,ar2,…,arn−1a, ar, ar^2, \dots, ar^{n-1}.

∑i=0n−1ari=a1−rn1−r(if r≠1)\sum_{i=0}^{n-1} ar^i = a \frac{1 - r^n}{1 - r} \quad (\text{if } r \neq 1)

Infinite Geometric Series: If ∣r∣<1|r| < 1, then ∑i=0∞ari=a1−r\sum_{i=0}^{\infty} ar^i = \frac{a}{1-r}.

3. Sum of Squares:

∑i=1ni2=n(n+1)(2n+1)6\sum_{i=1}^n i^2 = \frac{n(n+1)(2n+1)}{6}

4. Sum of Cubes:

∑i=1ni3=(n(n+1)2)2\sum_{i=1}^n i^3 = \left( \frac{n(n+1)}{2} \right)^2

    1. Harmonic Series: Hn=∑i=1n1iH_n = \sum_{i=1}^n \frac{1}{i}. Hn≈ln⁡n+γH_n \approx \ln n + \gamma, where γ≈0.577\gamma \approx 0.577 (Euler-Mascheroni constant).
    1. Telescoping Sums: A sum where intermediate terms cancel out.

∑i=1n(ai−ai+1)=(a1−a2)+(a2−a3)+⋯+(an−an+1)=a1−an+1\sum_{i=1}^n (a_i - a_{i+1}) = (a_1 - a_2) + (a_2 - a_3) + \dots + (a_n - a_{n+1}) = a_1 - a_{n+1}

Key Properties and Identities:

  • Linearity: ∑(c⋅ai+d⋅bi)=c∑ai+d∑bi\sum (c \cdot a_i + d \cdot b_i) = c \sum a_i + d \sum b_i.

  • Changing the limits of summation requires careful adjustment of the terms.

Common Pitfalls or Tricky Points:

  • Off-by-One Errors: Incorrectly determining the number of terms in a series (e.g., summing from i=0i = 0 to n−1n - 1 vs. i=1i = 1 to nn).

  • Incorrectly Identifying Series Type: Make sure it's truly arithmetic, geometric, or another standard type before applying formulas.

  • Convergence of Infinite Series: For infinite geometric series, ensure ∣r∣<1|r| < 1.

Standard Problem-Solving Techniques or Shortcuts:

  • Direct Formula Application: For standard series (arithmetic, geometric, sums of powers), memorize and apply the formulas.

  • Telescoping: Look for terms that can be expressed as differences, leading to cancellation.

  • Splitting Sums: Break a complex sum into multiple simpler sums using linearity.

  • Changing Index: Adjust the summation index to match standard formulas (e.g., starting from 0 or 1).

  • Integral Approximation: For sums that don't have a closed form, integrals can provide good upper and lower bounds (e.g., for harmonic series).

Quick Formula Reference

Permutations:

  • P(n,k)=n!(n−k)!P(n, k) = \frac{n!}{(n-k)!}

  • P(n,n)=n!P(n, n) = n!

  • Permutations with Repetition: n!n1!n2!…nk!\frac{n!}{n_1! n_2! \dots n_k!}

  • Circular Permutations: (n−1)!(n - 1)!

Combinations:

  • C(n,k)=(nk)=n!k!(n−k)!C(n, k) = \binom{n}{k} = \frac{n!}{k!(n-k)!}

  • Combinations with Repetition: C(n+k−1,k)C(n + k - 1, k)

  • Symmetry: C(n,k)=C(n,n−k)C(n, k) = C(n, n - k)

  • Pascal's Identity: C(n,k)=C(n−1,k)+C(n−1,k−1)C(n, k) = C(n - 1, k) + C(n - 1, k - 1)

  • Sum: ∑k=0nC(n,k)=2n\sum_{k=0}^n C(n, k) = 2^n

Balls In Bins:

  • Distinct Balls, Distinct Bins (any per bin): knk^n

  • Distinct Balls, Distinct Bins (at most one per bin): P(k,n)P(k, n)

  • Identical Balls, Distinct Bins (any per bin): C(n+k−1,k−1)C(n + k - 1, k - 1)

  • Identical Balls, Distinct Bins (at least one per bin): C(n−1,k−1)C(n - 1, k - 1)

  • Distinct Balls, Identical Bins (at least one per bin): S(n,k)S(n, k) (Stirling numbers of 2nd kind)

Principle of Inclusion-Exclusion (PIE):

  • ∣A∪B∣=∣A∣+∣B∣−∣A∩B∣|A \cup B| = |A| + |B| - |A \cap B|

  • ∣A∪B∪C∣=∣A∣+∣B∣+∣C∣−(∣A∩B∣+∣A∩C∣+∣B∩C∣)+∣A∩B∩C∣|A \cup B \cup C| = |A| + |B| + |C| - (|A \cap B| + |A \cap C| + |B \cap C|) + |A \cap B \cap C|

  • Derangements: Dn=n!∑k=0n(−1)kk!≈n!eD_n = n! \sum_{k=0}^n \frac{(-1)^k}{k!} \approx \frac{n!}{e}

Generating Functions:

  • 11−x=∑n=0∞xn\frac{1}{1-x} = \sum_{n=0}^{\infty} x^n

  • 11−ax=∑n=0∞(ax)n\frac{1}{1-ax} = \sum_{n=0}^{\infty} (ax)^n

  • (1+x)n=∑k=0nC(n,k)xk(1+x)^n = \sum_{k=0}^n C(n, k)x^k

  • 1(1−x)n=∑k=0∞C(n+k−1,k)xk\frac{1}{(1-x)^n} = \sum_{k=0}^{\infty} C(n+k-1, k)x^k

  • x(1−x)2=∑n=0∞nxn\frac{x}{(1-x)^2} = \sum_{n=0}^{\infty} nx^n

Modular Arithmetic:

  • Fermat's Little Theorem (pp prime, gcd⁡(a,p)=1\gcd(a, p) = 1): ap−1≡1(modp)a^{p-1} \equiv 1 \pmod p

  • Euler's Theorem (gcd⁡(a,n)=1\gcd(a, n) = 1): aϕ(n)≡1(modn)a^{\phi(n)} \equiv 1 \pmod n

  • Euler's Totient Function: ϕ(n)=n∏p∣n,p prime(1−1p)\phi(n) = n \prod_{p|n, p \text{ prime}} (1 - \frac{1}{p})

Pigeonhole Principle:

  • Basic: If nn pigeons in mm holes and n>mn > m, at least one hole has >1 pigeon.

  • Generalized: At least one hole has ⌈n/m⌉\lceil n/m \rceil pigeons.

Recurrence Relations:

  • Homogeneous Linear: an=c1an−1+⋯+ckan−ka_n = c_1 a_{n-1} + \dots + c_k a_{n-k} (solve characteristic equation rk−c1rk−1−⋯−ck=0r^k - c_1 r^{k-1} - \dots - c_k = 0).

  • Master Theorem: For T(n)=aT(n/b)+f(n)T(n) = aT(n/b) + f(n). Compare f(n)f(n) with nlog⁡ban^{\log_b a}.

Summation Formulas:

  • Arithmetic Series: ∑i=0n−1(a+id)=n2(2a+(n−1)d)\sum_{i=0}^{n-1} (a + id) = \frac{n}{2}(2a + (n-1)d)

  • Sum of first nn integers: ∑i=1ni=n(n+1)2\sum_{i=1}^n i = \frac{n(n+1)}{2}

  • Geometric Series: ∑i=0n−1ari=a1−rn1−r\sum_{i=0}^{n-1} ar^i = a \frac{1-r^n}{1-r}

  • Infinite Geometric Series (∣r∣<1|r| < 1): ∑i=0∞ari=a1−r\sum_{i=0}^{\infty} ar^i = \frac{a}{1-r}

  • Sum of Squares: ∑i=1ni2=n(n+1)(2n+1)6\sum_{i=1}^n i^2 = \frac{n(n+1)(2n+1)}{6}

  • Sum of Cubes: ∑i=1ni3=(n(n+1)2)2\sum_{i=1}^n i^3 = \left(\frac{n(n+1)}{2}\right)^2

Important Tips for GATE

    1. Read Carefully: Pay extreme attention to keywords like "distinct," "identical," "at least," "at most," "with replacement," "without replacement," "ordered," "unordered," "empty bins allowed," etc. These words dictate which formula or technique to use.
    1. Visualize and Simplify: For combinatorics and PHP problems, try to draw small examples or simplify the problem to a smaller scale to understand the underlying structure. This helps in correctly identifying pigeons/pigeonholes or the counting method.
    1. Master the Basics: Ensure you are fluent with fundamental permutations, combinations, and the stars and bars technique. Many complex problems are built upon these basic principles.
    1. Practice with PYQs: Solve previous year GATE questions diligently. This helps you understand the common patterns, tricky phrasing, and expected depth of knowledge. Pay attention to how different concepts are combined in a single question.
    1. Complementary Counting: For "at least" or "not allowed" type problems, consider using complementary counting (Total ways - Unwanted ways). This can often simplify the problem significantly compared to direct counting.
    1. Time Management for Recurrence Relations: For recurrence relations, if it's a divide-and-conquer type, try the Master Theorem first. If it's a linear recurrence, be quick with characteristic equations and solving for constants using initial conditions.
    1. Modular Arithmetic for Large Numbers: Always reduce intermediate results modulo mm in modular arithmetic. For large exponents, use Fermat's Little Theorem or Euler's Theorem to reduce the exponent modulo ϕ(m)\phi(m) (or p−1p - 1 if mm is prime).
    1. Don't Be Afraid of Casework: If a problem seems too complex for a single formula, break it down into mutually exclusive cases. Calculate each case separately and sum the results. Ensure cases are exhaustive.