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 distinct balls and distinct bins, each ball can go into any of the bins. Total ways: .
-
At most one ball per bin (injective mapping): This is equivalent to permutations. Total ways: if , and 0 otherwise.
2. Identical Balls into Distinct Bins
-
Any number of balls per bin (stars and bars): If there are identical balls and distinct bins, this is equivalent to finding non-negative integer solutions to . Total ways: .
-
At least one ball per bin (stars and bars with pre-allocation): First, place one ball in each bin, leaving balls to distribute. Total ways: if , and 0 otherwise.
- 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: .
-
At least one ball per bin: Total ways: .
- Identical Balls into Identical Bins: This is related to integer partitions.
-
Any number of balls per bin: The number of partitions of into at most parts, denoted .
-
At least one ball per bin: The number of partitions of into exactly parts, denoted . There is no simple closed-form formula; often solved using generating functions or recursion.
Key Properties and Identities:
-
The "stars and bars" formula 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 distinct items taken at a time: .
-
Permutations of distinct items taken at a time: .
-
Permutations with Repetition (multiset permutations): For items where there are identical items of type 1, of type 2, ..., of type , and . Total ways: .
-
Circular Permutations: For distinct items arranged in a circle, total ways: . If arrangements are symmetric (e.g., beads on a necklace), divide by 2: .
2. Combinations (Order Does Not Matter)
-
Combinations of distinct items taken at a time: .
-
Combinations with Repetition (multiset combinations): Selecting items from types with repetition allowed. Total ways: . This is equivalent to the "identical balls into distinct bins" problem.
3. Binomial Theorem
4. Multinomial Theorem
Key Properties and Identities:
-
Symmetry Identity: .
-
Pascal's Identity: .
-
Sum of Binomial Coefficients: .
-
Hockey-stick Identity: .
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 independent steps, and step can be performed in ways, then the total number of ways is .
- Principle of Addition: If a task can be performed in one of mutually exclusive ways, and way can be performed in ways, then the total number of ways is .
- 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: .
- For three sets: .
- General form for sets: [ \left| \bigcup_{i=1}^n A_i \right| = \sum_{i} |A_i| - \sum_{i
- Derangements: A permutation of objects such that no object remains in its original position. The number of derangements of objects, denoted or :
For large , .
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 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:
-
- Definition: For a sequence , its ordinary generating function (OGF) is .
-
- Common Generating Functions:
-
Constant sequence : .
-
Arithmetic progression : .
-
Binomial coefficients for fixed : .
-
Combinations with repetition for fixed : .
-
Sequence : .
-
Sequence : .
3. Operations on Generating Functions
-
Addition : If and , then .
-
Multiplication (Convolution) : If and , then , where . This is crucial for counting combinations of independent choices.
-
Differentiation : . So, .
-
Integration : .
-
Shift : (shifts coefficients to the right). (shifts coefficients to the left).
Key Properties and Identities:
-
The coefficient of in a generating function is , denoted .
-
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 :
-
- Write the recurrence relation.
-
- Multiply by and sum over all valid .
-
- Manipulate the sums to relate them to the generating function .
-
- Solve for as a rational function.
-
- Use partial fraction decomposition and known series expansions to find the coefficient of .
-
Counting Combinations : Represent each type of item or choice as a factor in the generating function. The coefficient of in the product of these factors gives the number of ways to choose 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:
-
- Congruence Relation : if divides , or equivalently, and have the same remainder when divided by .
2. Basic Properties :
-
If and , then:
-
-
-
-
for any positive integer .
-
- Modular Inverse: An integer is the modular multiplicative inverse of modulo if .
-
An inverse exists if and only if .
-
Can be found using the Extended Euclidean Algorithm.
-
- Euler's Totient Function : Counts the number of positive integers up to that are relatively prime to .
-
If (prime factorization), then .
-
If is prime, .
-
If is prime, .
-
- Fermat's Little Theorem: If is a prime number, then for any integer not divisible by , . Also, for any integer .
-
- Euler's Theorem: If and are coprime positive integers, then . (Fermat's Little Theorem is a special case of Euler's Theorem when is prime).
-
- Chinese Remainder Theorem (CRT): (Conceptually important, full formula rarely needed for GATE) If integers are pairwise coprime, then for any given integers , there exists an integer that solves the system of congruences:
Moreover, all solutions are congruent modulo .
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., ), division is not possible.
-
Negative Results: If a calculation yields a negative number, add the modulus until it's positive. E.g., .
-
Large Exponents: Always reduce the exponent modulo (if ) or modulo (if 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 by repeatedly squaring the base and reducing modulo . Example: if is even, if is odd.
Finding Modular Inverse:
-
Extended Euclidean Algorithm: For . If , then , so is the inverse.
-
Fermat's Little Theorem: If is prime, .
-
Euler's Theorem: If , .
-
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 items are put into
containers, with , 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:
-
- Basic Pigeonhole Principle: If pigeons are placed into pigeonholes, and , then at least one pigeonhole contains more than one pigeon.
-
- Generalized Pigeonhole Principle: If pigeons are placed into pigeonholes, then at least one pigeonhole must contain at least 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 .
- "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 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
- Characteristic Equation: .
- Distinct Roots: If are distinct roots, the general solution is .
- Repeated Roots: If a root has multiplicity , its contribution to the general solution is .
- The constants are determined by the initial conditions.
2. Linear Non-Homogeneous Recurrence Relations
- The general solution is , where is the homogeneous solution and is a particular solution.
- Finding : Guess a form for based on .
- ▪ If is a polynomial of degree , guess . If 1 is a root of the characteristic equation with multiplicity , multiply by .
- ▪ If is an exponential , guess . If is a root of the characteristic equation with multiplicity ,
multiply by .
-
- Master Theorem (for Divide and Conquer Recurrences): For recurrences of the form where , , and is asymptotically positive.
-
- If for some , then .
-
- If , then .
-
- If for some , AND for some and sufficiently large (regularity condition), then .
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 factors for repeated roots.
- Finding Particular Solutions: The guess for must be adjusted if it overlaps with the homogeneous solution.
- Boundary Conditions: Always use initial conditions to find the constants 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:
-
- Arithmetic Series: Sum of an arithmetic progression .
If , sum of first integers: .
-
- Geometric Series: Sum of a geometric progression .
Infinite Geometric Series: If , then .
3. Sum of Squares:
4. Sum of Cubes:
-
- Harmonic Series: . , where (Euler-Mascheroni constant).
-
- Telescoping Sums: A sum where intermediate terms cancel out.
Key Properties and Identities:
-
Linearity: .
-
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 to vs. to ).
-
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 .
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:
-
-
-
Permutations with Repetition:
-
Circular Permutations:
Combinations:
-
-
Combinations with Repetition:
-
Symmetry:
-
Pascal's Identity:
-
Sum:
Balls In Bins:
-
Distinct Balls, Distinct Bins (any per bin):
-
Distinct Balls, Distinct Bins (at most one per bin):
-
Identical Balls, Distinct Bins (any per bin):
-
Identical Balls, Distinct Bins (at least one per bin):
-
Distinct Balls, Identical Bins (at least one per bin): (Stirling numbers of 2nd kind)
Principle of Inclusion-Exclusion (PIE):
-
-
-
Derangements:
Generating Functions:
Modular Arithmetic:
-
Fermat's Little Theorem ( prime, ):
-
Euler's Theorem ():
-
Euler's Totient Function:
Pigeonhole Principle:
-
Basic: If pigeons in holes and , at least one hole has >1 pigeon.
-
Generalized: At least one hole has pigeons.
Recurrence Relations:
-
Homogeneous Linear: (solve characteristic equation ).
-
Master Theorem: For . Compare with .
Summation Formulas:
-
Arithmetic Series:
-
Sum of first integers:
-
Geometric Series:
-
Infinite Geometric Series ():
-
Sum of Squares:
-
Sum of Cubes:
Important Tips for GATE
-
- 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.
-
- 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.
-
- 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.
-
- 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.
-
- 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.
-
- 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.
-
- Modular Arithmetic for Large Numbers: Always reduce intermediate results modulo in modular arithmetic. For large exponents, use Fermat's Little Theorem or Euler's Theorem to reduce the exponent modulo (or if is prime).
-
- 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.
