100% FREE Updated: Mar 2026 Engineering Mathematics Discrete Mathematics

Combinatorics

Comprehensive study notes on Combinatorics for GATE CS preparation. This chapter covers key concepts, formulas, and examples needed for your exam.

Combinatorics

Overview

Combinatorics is a fundamental branch of discrete mathematics concerned with the systematic enumeration, combination, and arrangement of elements within finite or discrete structures. In the context of Computer Science, its principles are not merely abstract exercises but form the bedrock for analyzing algorithms, understanding data structures, and solving problems in areas such as network design, cryptography, and database theory. The ability to precisely count the number of possible outcomes, configurations, or computational steps is essential for determining the efficiency and feasibility of a given solution.

In this chapter, we shall embark on a structured exploration of this field, beginning with the foundational Counting Principles that govern basic enumeration. We will then progress to the study of Recurrence Relations, a powerful formalism for modeling problems that can be defined in terms of smaller, similar subproblems—a concept intimately familiar from the analysis of recursive algorithms. Finally, we will introduce Generating Functions, an elegant algebraic technique that provides a unified framework for solving complex recurrence relations and counting problems. A thorough command of these topics is indispensable for the GATE examination, where questions frequently test the application of combinatorial reasoning to assess algorithmic complexity and problem-solving aptitude.

---

Chapter Contents

| # | Topic | What You'll Learn |
|---|-------|-------------------|
| 1 | Counting Principles | Systematic enumeration using permutations and combinations. |
| 2 | Recurrence Relations | Modeling problems via recursively defined sequences. |
| 3 | Generating Functions | Solving recurrences using polynomial representations. |

---

Learning Objectives

By the End of This Chapter

After completing this chapter, you will be able to:

  • Apply the sum and product rules, permutations, and combinations to solve complex counting problems.

  • Formulate recurrence relations to model problems arising in algorithm analysis and discrete structures.

  • Solve linear homogeneous and non-homogeneous recurrence relations using characteristic equations and iterative methods.

  • Utilize generating functions to solve intricate recurrence relations and counting problems.

---

We now turn our attention to Counting Principles...

Part 1: Counting Principles

Introduction

In the study of discrete structures, combinatorics is the branch of mathematics concerned with counting. At its core, it seeks to answer the fundamental question: "How many ways can a certain task be done?" For the computer science student, a firm grasp of counting principles is not merely an academic exercise; it is foundational to the analysis of algorithms, the study of probability, the design of data structures, and the understanding of network protocols. The number of possible inputs to an algorithm, the size of a search space in artificial intelligence, or the number of possible network addresses are all problems rooted in combinatorics.

We begin our formal study by establishing the elementary rules upon which all combinatorial analysis is built. These principles, though simple in their statement, are remarkably powerful in their application. We will then proceed to the more structured concepts of permutations and combinations, which provide the vocabulary for discussing ordered and unordered arrangements. Finally, we will synthesize these ideas to tackle complex distribution problems, a frequent subject of inquiry in competitive examinations like GATE, by developing a systematic framework for their solution.

📖 Combinatorics

Combinatorics is the area of mathematics primarily concerned with counting, both as a means and an end in obtaining results, and with certain properties of finite structures. It deals with enumeration, combination, and permutation of sets of elements and the mathematical relations that characterize their properties.

---

The Fundamental Rules of Counting

All sophisticated counting techniques are ultimately derived from two elementary principles: the Rule of Sum and the Rule of Product. Understanding when and how to apply these rules is the first and most critical step in solving any combinatorial problem.

1. The Rule of Sum

The Rule of Sum applies when we must make a choice between two or more mutually exclusive tasks. If a task can be done in n1n_1 ways and a second, separate task can be done in n2n_2 ways, and the two tasks cannot be performed simultaneously, then there are n1+n2n_1 + n_2 ways to perform one of these tasks.

Consider a student who must choose one elective course. If there are 5 courses available from the Mathematics department and 4 courses available from the Physics department, and the student can only choose one course in total, the number of choices is 5+4=95 + 4 = 9. The key is that the choices are disjoint; selecting a math course precludes selecting a physics course.

2. The Rule of Product

The Rule of Product applies when a procedure consists of a sequence of independent tasks. If a procedure can be broken down into a sequence of two tasks, and there are n1n_1 ways to do the first task and for each of these ways, there are n2n_2 ways to do the second task, then there are n1×n2n_1 \times n_2 ways to do the entire procedure.

For instance, to form a 2-character license plate where the first character must be a letter from {A, B, C} and the second must be a digit from {1, 2, 3, 4}, we apply the Rule of Product. There are 3 choices for the first position and 4 choices for the second. The total number of unique license plates is 3×4=123 \times 4 = 12.

3. The Principle of Complementation

Often, counting the number of outcomes in an event EE is complicated, whereas counting the number of outcomes not in EE (denoted EE') is significantly simpler. If UU is the universal set of all possible outcomes, then the number of outcomes in EE is given by E=UE|E| = |U| - |E'|. This is known as complementary counting.

This principle is particularly useful for problems involving phrases like "at least one" or "not all".

Worked Example:

Problem: How many binary strings of length 8 contain at least one '1'?

Solution:

Step 1: Define the universal set UU and the event EE.
The universal set UU is the set of all binary strings of length 8. The event EE is the set of such strings with at least one '1'.

Step 2: Calculate the size of the universal set, U|U|.
Each of the 8 positions in the string can be either a '0' or a '1'. By the Rule of Product, the total number of strings is:

U=2×2××2 (8 times)=28=256|U| = 2 \times 2 \times \dots \times 2 \text{ (8 times)} = 2^8 = 256

Step 3: Define the complement event EE' and calculate its size.
The complement event EE' is the set of strings with no '1's. This means the string must consist of all '0's. There is only one such string: "00000000".

E=1|E'| = 1

Step 4: Apply the Principle of Complementation.

E=UE=2561=255|E| = |U| - |E'| = 256 - 1 = 255

Answer: There are 255 binary strings of length 8 containing at least one '1'.

---

---

Permutations and Combinations

We now turn our attention to two of the most central concepts in combinatorics: permutations and combinations. The critical distinction between them lies in whether the order of selection is relevant.

1. Permutations: Ordered Arrangements

A permutation is an arrangement of objects in a specific order.

📖 Permutation

A permutation of a set of distinct objects is an ordered arrangement of these objects. An ordered arrangement of kk elements of a set of nn distinct objects is called a kk-permutation.

The number of kk-permutations of a set of nn distinct objects is denoted by P(n,k)P(n, k) or nPk^nP_k.

📐 Permutations of n distinct objects taken k at a time
P(n,k)=n!(nk)!P(n, k) = \frac{n!}{(n-k)!}

Variables:

    • nn = total number of distinct objects available.

    • kk = number of objects to be arranged.


When to use: When selecting kk objects from nn and the order in which they are arranged matters. Examples include arranging people for a photo, assigning specific roles (President, VP), or ordering letters in a word.

A special case arises when we arrange all nn objects (k=nk=n). The number of permutations is P(n,n)=n!P(n,n) = n!.

Worked Example:

Problem: From a group of 10 students, a president, a vice-president, and a treasurer are to be chosen. In how many ways can these positions be filled?

Solution:

Step 1: Identify nn and kk.
We are selecting 3 students from a group of 10 to fill distinct roles. Thus, the order of selection matters.
n=10n = 10 (total students)
k=3k = 3 (positions to fill)

Step 2: Apply the permutation formula.
This is a problem of finding the number of 3-permutations from a set of 10.

P(10,3)=10!(103)!P(10, 3) = \frac{10!}{(10-3)!}

Step 3: Simplify the expression.

P(10,3)=10!7!=10×9×8×7!7!P(10, 3) = \frac{10!}{7!} = \frac{10 \times 9 \times 8 \times 7!}{7!}

Step 4: Compute the final answer.

P(10,3)=10×9×8=720P(10, 3) = 10 \times 9 \times 8 = 720

Answer: There are 720 ways to fill the positions.

2. Combinations: Unordered Selections

A combination is a selection of objects where the order of selection does not matter.

📖 Combination

A combination is a selection of items from a set that has distinct members, such that the order of selection does not matter. An unordered selection of kk elements from a set of nn distinct objects is called a kk-combination.

The number of kk-combinations of a set of nn distinct objects is denoted by C(n,k)C(n, k), (nk)\binom{n}{k}, or nCk^nC_k.

📐 Combinations of n distinct objects taken k at a time
C(n,k)=(nk)=n!k!(nk)!C(n, k) = \binom{n}{k} = \frac{n!}{k!(n-k)!}

Variables:

    • nn = total number of distinct objects available.

    • kk = number of objects to be selected.


When to use: When selecting kk objects from nn and the order of selection is irrelevant. Examples include forming a committee, choosing a subset of items, or dealing a hand of cards.

Worked Example:

Problem: From a group of 10 students, a committee of 3 is to be formed. In how many ways can this be done?

Solution:

Step 1: Identify nn and kk.
We are selecting 3 students from a group of 10. Since it is a committee, all members have equal standing, and the order of selection is irrelevant.
n=10n = 10 (total students)
k=3k = 3 (committee size)

Step 2: Apply the combination formula.
This is a problem of finding the number of 3-combinations from a set of 10.

C(10,3)=(103)=10!3!(103)!C(10, 3) = \binom{10}{3} = \frac{10!}{3!(10-3)!}

Step 3: Simplify the expression.

C(10,3)=10!3!7!=10×9×8×7!(3×2×1)×7!C(10, 3) = \frac{10!}{3!7!} = \frac{10 \times 9 \times 8 \times 7!}{ (3 \times 2 \times 1) \times 7!}

Step 4: Compute the final answer.

C(10,3)=10×9×86=10×3×4=120C(10, 3) = \frac{10 \times 9 \times 8}{6} = 10 \times 3 \times 4 = 120

Answer: There are 120 ways to form the committee.

---

Advanced Counting: The Distribution Framework

Many combinatorial problems can be framed as distributing nn objects into kk boxes. The solution strategy depends critically on whether the objects and boxes are distinguishable (distinct) or indistinguishable (identical).

1. Distinct Objects into Distinct Boxes

This is the most straightforward case. Each of the nn distinct objects can be placed into any of the kk distinct boxes. By the Rule of Product, there are kk choices for the first object, kk for the second, and so on.

The total number of ways is knk^n.

Constraint: Every box must receive at least one object (Surjections).
This is a more complex scenario that arises frequently. We seek the number of surjective (onto) functions from a set of size nn to a set of size kk. This can be calculated using the Principle of Inclusion-Exclusion.

📐 Surjections (Distinct Objects to Distinct Boxes, Non-Empty)

The number of ways to distribute nn distinct objects into kk distinct boxes such that no box is empty is:

N=i=0k(1)i(ki)(ki)nN = \sum_{i=0}^{k} (-1)^i \binom{k}{i} (k-i)^n

Variables:

    • nn = number of distinct objects.

    • kk = number of distinct boxes.


When to use: When assigning distinct items (e.g., jobs, people) to distinct recipients (e.g., computers, teams) with the condition that every recipient must get at least one item.

2. Identical Objects into Distinct Boxes (Stars and Bars)

When objects are identical, we are only concerned with how many objects are in each distinct box. We can model this problem by arranging nn identical items (stars) and k1k-1 dividers (bars). The number of stars before the first bar is the count for the first box, the number between the first and second bar is for the second box, and so on.

This is equivalent to finding the number of non-negative integer solutions to the equation x1+x2++xk=nx_1 + x_2 + \dots + x_k = n.

📐 Stars and Bars
C(n+k1,k1)=(n+k1n)C(n+k-1, k-1) = \binom{n+k-1}{n}

Variables:

    • nn = number of identical objects.

    • kk = number of distinct boxes.


When to use: When distributing identical items (e.g., units of money, identical balls) into distinct containers (e.g., people, numbered bins).

Worked Example:

Problem: In how many ways can 10 identical chocolates be distributed among 4 distinct children?

Solution:

Step 1: Identify the model, nn, and kk.
This is a problem of distributing identical objects (chocolates) into distinct boxes (children). We can use the Stars and Bars formula.
n=10n = 10
k=4k = 4

Step 2: Apply the formula.
We need to find the number of ways to arrange 1010 stars and 41=34-1=3 bars. The total number of positions is 10+3=1310+3=13. We need to choose 33 positions for the bars (or 1010 for the stars).

C(10+41,41)=C(13,3)C(10+4-1, 4-1) = C(13, 3)

Step 3: Calculate the result.

C(13,3)=13!3!(133)!=13!3!10!=13×12×113×2×1C(13, 3) = \frac{13!}{3!(13-3)!} = \frac{13!}{3!10!} = \frac{13 \times 12 \times 11}{3 \times 2 \times 1}
C(13,3)=13×2×11=286C(13, 3) = 13 \times 2 \times 11 = 286

Answer: There are 286 ways to distribute the chocolates.

3. Identical Objects into Identical Boxes (Integer Partitions)

This is the most constrained case. Since both objects and boxes are identical, the only thing that matters is the size of the groups of objects. This problem is equivalent to finding the number of partitions of the integer nn into at most kk parts.

There is no simple closed-form formula for this. For GATE-level problems, this is typically solved by careful, systematic enumeration.

Worked Example:

Problem: Find the number of ways to distribute 6 identical balls into 3 identical bins.

Solution:

Step 1: Frame the problem as an integer partition.
We need to find the number of ways to write 6 as a sum of at most 3 positive integers. The order of the summands does not matter since the bins are identical.

Step 2: Systematically enumerate all possible partitions of 6.
Let the number of balls in the bins be (b1,b2,b3)(b_1, b_2, b_3) such that b1+b2+b3=6b_1 + b_2 + b_3 = 6 and b1b2b30b_1 \ge b_2 \ge b_3 \ge 0.

* Partition into 1 part (2 bins are empty):
(6,0,0)(6, 0, 0) - This is one way. The grouping is just {6}\{6\}.

* Partitions into 2 parts (1 bin is empty):
(5,1,0)(5, 1, 0)
(4,2,0)(4, 2, 0)
(3,3,0)(3, 3, 0)

* Partitions into 3 parts (no bins are empty):
(4,1,1)(4, 1, 1)
(3,2,1)(3, 2, 1)
(2,2,2)(2, 2, 2)

Step 3: Count the total number of unique partitions.
Summing up the possibilities: 11 (from 1 part) + 33 (from 2 parts) + 33 (from 3 parts) = 77.

Answer: There are 7 ways to distribute the balls.

---

Problem-Solving Strategies

💡 GATE Strategy: The Element-wise Approach

For problems involving relationships between subsets (e.g., ABSA \subseteq B \subseteq S), do not try to count the sets AA and BB directly. Instead, consider each element xx in the universal set SS and determine the number of possible states it can be in with respect to the subsets.

For ABA \subseteq B, each element xSx \in S has three possibilities:

  • xBx \notin B (and thus xAx \notin A)

  • xBx \in B but xAx \notin A

  • xBx \in B and xAx \in A

If S=n|S| = n, there are nn such independent choices. By the Rule of Product, the total number of valid pairs (A,B)(A, B) is 3n3^n.

💡 GATE Strategy: Grouping and Blocking

When a problem requires certain elements to appear contiguously or in a specific relative order, treat those elements as a single "block".

  • Calculate the number of ways to arrange the blocks and the other individual elements.

  • Calculate the number of ways to arrange the elements within each block.

  • Multiply these results using the Rule of Product.

This was relevant to the PYQ about separating sets AA and BB in a permutation.

---

Common Mistakes

⚠️ Avoid These Errors
    • Confusing Permutations and Combinations: Always ask: "Does the order of selection matter?" If yes, use permutation. If no, use combination. Choosing a president and VP is a permutation; choosing a 2-person committee is a combination.
    • Misinterpreting "Identical" vs. "Distinct": This is the most critical distinction in distribution problems. Using a Stars and Bars formula for distinct objects will lead to a completely wrong answer. Always categorize the objects and boxes first.
    • Forgetting Constraints: In problems with conditions like "at least one" or "at most kk", these constraints must be handled explicitly, often through complementary counting or more advanced techniques like Inclusion-Exclusion. Simply applying a basic formula is insufficient.
    • Incorrectly Using Complementary Counting: Ensure that the complement you are counting is the exact logical opposite of the desired event. For "at least one", the complement is "none". For "at least two", the complement is "none or one".

---

---

Practice Questions

:::question type="NAT" question="A programming team of 5 members is to be formed from a group of 6 senior programmers and 8 junior programmers. The team must have at least 2 senior programmers. How many such teams can be formed?" answer="1526" hint="Consider the possible cases for the number of senior programmers (2, 3, 4, or 5) and sum the results. Alternatively, use complementary counting." solution="
Method 1: Case-by-case Analysis

The team must have at least 2 senior programmers. The total team size is 5.
Let SS denote Senior programmers and JJ denote Junior programmers.

Case 1: 2 Seniors and 3 Juniors
Number of ways = (Ways to choose 2 SS from 6) ×\times (Ways to choose 3 JJ from 8)

=(62)×(83)= \binom{6}{2} \times \binom{8}{3}

=6×52×1×8×7×63×2×1= \frac{6 \times 5}{2 \times 1} \times \frac{8 \times 7 \times 6}{3 \times 2 \times 1}

=15×56= 15 \times 56

=840= 840

Case 2: 3 Seniors and 2 Juniors

=(63)×(82)= \binom{6}{3} \times \binom{8}{2}

=6×5×43×2×1×8×72×1= \frac{6 \times 5 \times 4}{3 \times 2 \times 1} \times \frac{8 \times 7}{2 \times 1}

=20×28= 20 \times 28

=560= 560

Case 3: 4 Seniors and 1 Junior

=(64)×(81)= \binom{6}{4} \times \binom{8}{1}

=(62)×8= \binom{6}{2} \times 8

=15×8= 15 \times 8

=120= 120

Case 4: 5 Seniors and 0 Juniors

=(65)×(80)= \binom{6}{5} \times \binom{8}{0}

=(61)×1= \binom{6}{1} \times 1

=6×1= 6 \times 1

=6= 6

Total ways:

840+560+120+6=1526840 + 560 + 120 + 6 = 1526

Method 2: Complementary Counting

Total number of ways to form a team of 5 from 14 programmers (6S+8J6S + 8J) is:

U=(145)|U| = \binom{14}{5}

=14×13×12×11×105×4×3×2×1= \frac{14 \times 13 \times 12 \times 11 \times 10}{5 \times 4 \times 3 \times 2 \times 1}

=14×13×11= 14 \times 13 \times 11

=2002= 2002

The unwanted cases are teams with 0 or 1 senior programmer.
Unwanted Case 1: 0 Seniors and 5 Juniors

=(60)×(85)= \binom{6}{0} \times \binom{8}{5}

=1×(83)= 1 \times \binom{8}{3}

=1×56= 1 \times 56

=56= 56

Unwanted Case 2: 1 Senior and 4 Juniors

=(61)×(84)= \binom{6}{1} \times \binom{8}{4}

=6×8×7×6×54×3×2×1= 6 \times \frac{8 \times 7 \times 6 \times 5}{4 \times 3 \times 2 \times 1}

=6×70= 6 \times 70

=420= 420

Total unwanted ways = 56+420=47656 + 420 = 476.

Result:
Required ways = Total ways - Unwanted ways

=2002476= 2002 - 476

=1526= 1526

Answer: 1526\boxed{1526}
"
:::

:::question type="MCQ" question="In how many ways can the letters of the word 'ENGINEER' be arranged such that the arrangement does not start and end with 'E'?" options=["3360","2400","960","3000"] answer="3000" hint="Use complementary counting. Find the total number of arrangements and subtract the number of arrangements where the first and last letters are both 'E'." solution="
Step 1: Calculate the total number of arrangements of the word 'ENGINEER'.
The word 'ENGINEER' has 8 letters.
The letter 'E' appears 3 times.
The letter 'N' appears 2 times.
The letters 'G', 'I', 'R' appear 1 time each.
Total arrangements = 8!3!2!\frac{8!}{3!2!}

=403206×2= \frac{40320}{6 \times 2}

=4032012= \frac{40320}{12}

=3360= 3360

Step 2: Calculate the number of 'unwanted' arrangements, where the string starts and ends with 'E'.
Fix 'E' at the first position and 'E' at the last position.
The remaining 6 letters to arrange are {N, G, I, N, E, R}.
In this set, 'N' appears 2 times.
Number of ways to arrange these 6 letters = 6!2!\frac{6!}{2!}

=7202= \frac{720}{2}

=360= 360

Step 3: Apply the principle of complementation.
Number of desired arrangements = Total arrangements - Unwanted arrangements

=3360360= 3360 - 360

=3000= 3000

Answer: 3000\boxed{3000}
"
:::

:::question type="NAT" question="Let S={1,2,3,,12}S = \{1, 2, 3, \dots, 12\}. The number of ordered pairs of subsets (A,B)(A, B) of SS such that AB=2|A \cap B| = 2 is ________." answer="3897234" hint="First, choose the 2 elements that will be in the intersection. Then, for each of the remaining elements in S, determine its possible location with respect to sets A and B." solution="
Step 1: Choose the 2 elements for the intersection ABA \cap B.
The universal set SS has 12 elements. We need to choose 2 elements that will belong to both AA and BB.
Number of ways to choose these 2 elements = (122)\binom{12}{2}.

(122)=12×112×1\binom{12}{2} = \frac{12 \times 11}{2 \times 1}

=66= 66

Step 2: Consider the remaining elements.
There are 122=1012 - 2 = 10 elements remaining in SS. For any element xx from these 10 elements, there are three possibilities for its membership in AA and BB:

  • xAx \in A and xBx \notin B (i.e., xABx \in A \setminus B)

  • xAx \notin A and xBx \in B (i.e., xBAx \in B \setminus A)

  • xAx \notin A and xBx \notin B (i.e., xABx \notin A \cup B)

  • These 10 elements cannot be in ABA \cap B as we have already chosen the 2 elements for the intersection.

    Step 3: Apply the Rule of Product for the remaining 10 elements.
    Each of the 10 elements has 3 independent choices for its location.
    So, the number of ways to place these 10 elements is 3103^{10}.

    310=(35)23^{10} = (3^5)^2

    =2432= 243^2

    =59049= 59049

    Step 4: Combine the results from Step 1 and Step 3.
    The total number of ordered pairs (A,B)(A, B) is the product of the number of ways to choose the intersection and the number of ways to place the remaining elements.

    Total ways=(122)×310\text{Total ways} = \binom{12}{2} \times 3^{10}

    Total ways=66×59049\text{Total ways} = 66 \times 59049

    Total ways=3897234\text{Total ways} = 3897234

    Answer: 3897234\boxed{3897234}
    "
    :::

    :::question type="MSQ" question="Which of the following statements are correct for distributing 5 distinct jobs to 3 distinct processors?" options=["The total number of ways to distribute the jobs without any restrictions is 243.","The number of ways to distribute the jobs such that each processor gets at least one job is 150.","If one specific processor must get exactly 2 jobs, the number of ways is 80.","The number of ways such that no processor is idle is 90."] answer="A,B,C" hint="For A, use the basic distinct-to-distinct formula. For B, use the surjection formula (Inclusion-Exclusion). For C, first choose the 2 jobs for the specific processor, then distribute the rest. For D, check if it matches B." solution="
    Let n=5n=5 (distinct jobs) and k=3k=3 (distinct processors).

    Option A: Total number of ways without restrictions.
    Each of the 5 jobs can be assigned to any of the 3 processors.
    By the Rule of Product, total ways = 35=2433^5 = 243.
    Thus, statement A is correct.

    Option B: Each processor gets at least one job (no processor is idle).
    This is a surjection problem. We use the Principle of Inclusion-Exclusion.

    N=(30)(30)5(31)(31)5+(32)(32)5(33)(33)5N = \binom{3}{0}(3-0)^5 - \binom{3}{1}(3-1)^5 + \binom{3}{2}(3-2)^5 - \binom{3}{3}(3-3)^5

    N=1×353×25+3×151×05N = 1 \times 3^5 - 3 \times 2^5 + 3 \times 1^5 - 1 \times 0^5

    N=2433×32+3×10N = 243 - 3 \times 32 + 3 \times 1 - 0

    N=150N = 150

    Thus, statement B is correct.

    Option C: One specific processor must get exactly 2 jobs.
    Step C1: Choose 2 jobs for the specific processor (say P1) out of 5. This can be done in (52)\binom{5}{2} ways.

    (52)=5×42×1=10\binom{5}{2} = \frac{5 \times 4}{2 \times 1} = 10

    Step C2: The remaining 52=35-2=3 jobs must be distributed among the remaining 31=23-1=2 processors (P2, P3).
    Each of these 3 jobs can go to either P2 or P3. So, there are 23=82^3 = 8 ways.
    Step C3: Total ways = (Ways to choose jobs for P1) ×\times (Ways to distribute remaining jobs)
    Total ways = 10×8=8010 \times 8 = 80.
    Thus, statement C is correct.

    Option D: The number of ways such that no processor is idle is 90.
    From our calculation for Option B, the number of ways such that no processor is idle is 150.
    Thus, statement D is incorrect.

    Answer: A,B,C\boxed{A,B,C}
    "
    :::

    ---

    Summary

    Key Takeaways for GATE

    • Identify the Nature of Objects and Boxes: The first step in any counting problem is to determine if the items being counted (objects) and the categories they are placed into (boxes) are distinct or identical. This single decision dictates the entire solution path.

    • Master Permutations vs. Combinations: Permutations are for ordered arrangements (P(n,k)P(n,k)), while Combinations are for unordered selections (C(n,k)C(n,k)). Misidentifying this is a frequent source of error.

    • Leverage Strategic Counting: For complex problems, direct counting is often difficult. Remember to use powerful strategies like the Principle of Complementation (for "at least one" scenarios), the Element-wise Approach (for subset problems), and Grouping/Blocking (for contiguity constraints).

    • Know the Four Distribution Cases:

    Distinct objects to distinct boxes: knk^n.
    Identical objects to distinct boxes: C(n+k1,k1)C(n+k-1, k-1) (Stars and Bars).
    Distinct objects to identical boxes: Stirling Numbers (less common, but know the concept).
    Identical objects to identical boxes: Integer Partitions (enumeration).

    ---

    What's Next?

    💡 Continue Learning

    This topic connects to:

      • Probability: The counting principles discussed here are the absolute foundation for calculating probabilities in a discrete sample space. The probability of an event is the ratio of favorable outcomes to total possible outcomes, both of which are found using combinatorics.

      • Recurrence Relations: Many counting problems can also be modeled using recurrence relations. For example, the number of binary strings of length nn without consecutive 11s can be solved using a recurrence, providing an alternative to direct combinatorial arguments. Understanding both methods provides a deeper insight into problem-solving.


    Master these connections for comprehensive GATE preparation!

    ---

    💡 Moving Forward

    Now that you understand Counting Principles, let's explore Recurrence Relations which builds on these concepts.

    ---

    Part 2: Recurrence Relations

    Introduction

    A recurrence relation is a mathematical equation that recursively defines a sequence of values. Each term of the sequence is defined as a function of the preceding terms. In the context of computer science, recurrence relations arise naturally in the analysis of recursive algorithms, where they describe the computational complexity, or running time, as a function of the input size. The process of finding a closed-form, non-recursive expression for a sequence defined by a recurrence relation is known as "solving" the recurrence.

    Mastery of this topic is indispensable for the GATE examination, as it forms the bedrock of algorithm analysis. Questions frequently test the ability to solve various classes of recurrences, from simple linear forms to more complex divide-and-conquer relations. We shall explore the principal methods for solving these relations, focusing on the techniques most relevant to the competitive examination setting.

    📖 Recurrence Relation

    A recurrence relation for a sequence {an}\{a_n\} is an equation that expresses the term ana_n in terms of one or more of its predecessors, a0,a1,,an1a_0, a_1, \dots, a_{n-1}, for all integers nn greater than or equal to some initial value n0n_0. The initial values provided for a finite number of terms, such as a0,a1,,an01a_0, a_1, \dots, a_{n_0-1}, are called the base cases or initial conditions.

    ---

    Key Concepts

    1. Linear Homogeneous Recurrence Relations

    We begin with one of the most common forms of recurrence relations encountered in discrete mathematics.

    A recurrence relation is said to be linear if the terms of the sequence appear only in the first power and are not multiplied together. It is homogeneous if every term involves a term of the sequence. It has constant coefficients if the coefficients of the sequence terms are fixed constants. The general form of a kk-th order linear homogeneous recurrence relation with constant coefficients is:

    an=c1an1+c2an2++ckanka_n = c_1 a_{n-1} + c_2 a_{n-2} + \dots + c_k a_{n-k}

    where ciRc_i \in \mathbb{R} are constants and ck0c_k \neq 0.

    To solve such a relation, we assume a solution of the form an=rna_n = r^n for some constant r0r \neq 0. Substituting this into the relation yields:

    rn=c1rn1+c2rn2++ckrnkr^n = c_1 r^{n-1} + c_2 r^{n-2} + \dots + c_k r^{n-k}

    Dividing by rnkr^{n-k} (since r0r \neq 0), we obtain the characteristic equation:

    rkc1rk1c2rk2ck=0r^k - c_1 r^{k-1} - c_2 r^{k-2} - \dots - c_k = 0

    The solution to the recurrence is determined by the roots of this polynomial.

    Case A: Distinct Roots

    If the characteristic equation has kk distinct roots r1,r2,,rkr_1, r_2, \dots, r_k, the general solution to the recurrence relation is a linear combination of these roots raised to the power of nn:

    an=α1r1n+α2r2n++αkrkna_n = \alpha_1 r_1^n + \alpha_2 r_2^n + \dots + \alpha_k r_k^n

    The constants α1,α2,,αk\alpha_1, \alpha_2, \dots, \alpha_k are determined using the given initial conditions.

    Worked Example (Distinct Roots):

    Problem: Solve the recurrence relation an=an1+6an2a_n = a_{n-1} + 6a_{n-2} for n2n \ge 2, with initial conditions a0=1a_0 = 1 and a1=8a_1 = 8.

    Solution:

    Step 1: Formulate the characteristic equation.
    The recurrence is anan16an2=0a_n - a_{n-1} - 6a_{n-2} = 0. We assume a solution of the form an=rna_n = r^n.

    r2r6=0r^2 - r - 6 = 0

    Step 2: Find the roots of the characteristic equation.
    Factoring the quadratic equation gives:

    (r3)(r+2)=0(r-3)(r+2) = 0

    The roots are distinct: r1=3r_1 = 3 and r2=2r_2 = -2.

    Step 3: Write the general form of the solution.
    Since the roots are distinct, the general solution is:

    an=α1(3)n+α2(2)na_n = \alpha_1 (3)^n + \alpha_2 (-2)^n

    Step 4: Use the initial conditions to find the constants α1\alpha_1 and α2\alpha_2.
    For n=0n=0:

    a0=1=α1(3)0+α2(2)0    1=α1+α2(1)a_0 = 1 = \alpha_1 (3)^0 + \alpha_2 (-2)^0 \implies 1 = \alpha_1 + \alpha_2 \quad (1)

    For n=1n=1:
    a1=8=α1(3)1+α2(2)1    8=3α12α2(2)a_1 = 8 = \alpha_1 (3)^1 + \alpha_2 (-2)^1 \implies 8 = 3\alpha_1 - 2\alpha_2 \quad (2)

    We now have a system of two linear equations. Multiplying equation (1) by 2 and adding it to equation (2) gives:
    2(1)+8=2(α1+α2)+(3α12α2)2(1) + 8 = 2(\alpha_1 + \alpha_2) + (3\alpha_1 - 2\alpha_2)

    10=5α110 = 5\alpha_1

    α1=2\alpha_1 = 2

    Substituting α1=2\alpha_1 = 2 into equation (1) gives:
    1=2+α21 = 2 + \alpha_2

    α2=1\alpha_2 = -1

    Step 5: State the final closed-form solution.

    an=23n(2)na_n = 2 \cdot 3^n - (-2)^n

    Answer: The solution is an=23n(2)n\boxed{a_n = 2 \cdot 3^n - (-2)^n}.

    Case B: Repeated Roots

    If a root r1r_1 of the characteristic equation has multiplicity mm, then the part of the general solution corresponding to this root is:

    (α1+α2n+α3n2++αmnm1)r1n(\alpha_1 + \alpha_2 n + \alpha_3 n^2 + \dots + \alpha_m n^{m-1}) r_1^n

    This polynomial in nn is multiplied by r1nr_1^n. The same principle applies to all repeated roots.

    ---

    ---

    2. Linear Non-Homogeneous Recurrence Relations

    A linear non-homogeneous recurrence relation with constant coefficients has the form:

    an=c1an1+c2an2++ckank+f(n)a_n = c_1 a_{n-1} + c_2 a_{n-2} + \dots + c_k a_{n-k} + f(n)

    The term f(n)f(n) is the non-homogeneous part. The solution to such a relation is the sum of two parts:

    an=an(h)+an(p)a_n = a_n^{(h)} + a_n^{(p)}

    where an(h)a_n^{(h)} is the solution to the associated homogeneous recurrence (i.e., with f(n)=0f(n)=0), and an(p)a_n^{(p)} is a particular solution that depends on the form of f(n)f(n).

    Finding an(h)a_n^{(h)} is done using the characteristic equation method described previously. To find an(p)a_n^{(p)}, we use the method of undetermined coefficients, where we guess a solution form for an(p)a_n^{(p)} that mirrors f(n)f(n).

    | Form of f(n)f(n) | Guess for Particular Solution an(p)a_n^{(p)} |
    | :------------------------------------------------- | :---------------------------------------- |
    | Constant, CC | Constant, AA |
    | Polynomial in nn of degree dd, P(n)P(n) | Polynomial in nn of degree dd |
    | Exponential, CsnC \cdot s^n | AsnA \cdot s^n |
    | Polynomial ×\times Exponential, P(n)snP(n) \cdot s^n | (Polynomial of degree dd) sn\cdot s^n |

    Special Case: Root Collision

    If the guessed form for the particular solution an(p)a_n^{(p)} is already a part of the homogeneous solution an(h)a_n^{(h)}, the guess must be modified. Specifically, if the non-homogeneous term involves sns^n and ss is a characteristic root with multiplicity mm, the guessed form must be multiplied by nmn^m.

    Worked Example (Non-Homogeneous):

    Problem: Find the asymptotic behavior of T(n)=2T(n1)+n2nT(n) = 2T(n-1) + n2^n for n>0n>0, with T(0)=1T(0)=1.

    Solution:

    Step 1: Find the solution to the associated homogeneous recurrence.
    The homogeneous part is T(n)2T(n1)=0T(n) - 2T(n-1) = 0. The characteristic equation is:

    r2=0    r=2r - 2 = 0 \implies r = 2

    The homogeneous solution is Tn(h)=α1(2n)T_n^{(h)} = \alpha_1 (2^n).

    Step 2: Determine the form of the particular solution.
    The non-homogeneous part is f(n)=n2nf(n) = n2^n, which is a polynomial of degree 1 multiplied by an exponential term 2n2^n. The base of the exponential term, s=2s=2, matches the characteristic root r=2r=2. This is a root collision.

    Our initial guess would be (An+B)2n(An+B)2^n. Because s=2s=2 is a characteristic root of multiplicity m=1m=1, we must multiply our guess by nm=n1=nn^m = n^1 = n.
    The correct form for the particular solution is:

    Tn(p)=n(An+B)2n=(An2+Bn)2nT_n^{(p)} = n(An+B)2^n = (An^2 + Bn)2^n

    Step 3: Substitute the particular solution into the original recurrence to find the coefficients.

    (An2+Bn)2n=2[A(n1)2+B(n1)]2n1+n2n(An^2 + Bn)2^n = 2[A(n-1)^2 + B(n-1)]2^{n-1} + n2^n

    Divide the entire equation by 2n12^{n-1}:

    2(An2+Bn)=2[A(n22n+1)+B(n1)]+2n2(An^2 + Bn) = 2[A(n^2 - 2n + 1) + B(n-1)] + 2n
    2An2+2Bn=2An24An+2A+2Bn2B+2n2An^2 + 2Bn = 2An^2 - 4An + 2A + 2Bn - 2B + 2n

    Simplifying by canceling terms:

    0=4An+2A2B+2n0 = -4An + 2A - 2B + 2n
    0=(24A)n+(2A2B)0 = (2-4A)n + (2A-2B)

    For this equation to hold for all nn, the coefficients of the powers of nn must be zero.
    Coefficient of nn:

    24A=0    A=1/22-4A = 0 \implies A = 1/2

    Constant term:
    2A2B=0    2(1/2)2B=0    12B=0    B=1/22A-2B = 0 \implies 2(1/2) - 2B = 0 \implies 1-2B = 0 \implies B=1/2

    Step 4: Write the particular and general solutions.
    The particular solution is:

    Tn(p)=(12n2+12n)2n=n(n+1)22nT_n^{(p)} = \left(\frac{1}{2}n^2 + \frac{1}{2}n\right)2^n = \frac{n(n+1)}{2}2^n

    The general solution is T(n)=Tn(h)+Tn(p)T(n) = T_n^{(h)} + T_n^{(p)}:

    T(n)=α12n+n(n+1)22nT(n) = \alpha_1 2^n + \frac{n(n+1)}{2}2^n

    (Finding α1\alpha_1 using T(0)=1T(0)=1 is possible but not required for asymptotic analysis).

    Step 5: Determine the asymptotic behavior.
    The general solution is dominated by the term with the highest growth rate. Comparing α12n\alpha_1 2^n with n(n+1)22n\frac{n(n+1)}{2}2^n, the latter term, which is Θ(n22n)\Theta(n^2 2^n), grows faster.

    Answer: T(n)=Θ(n22n)\boxed{T(n) = \Theta(n^2 2^n)}.

    ---

    3. Divide-and-Conquer Recurrences: The Master Theorem

    Many recursive algorithms follow a divide-and-conquer strategy, leading to recurrences of a specific form. The Master Theorem provides a "cookbook" method for solving such recurrences.

    📐 Master Theorem

    Let T(n)T(n) be a monotonically increasing function satisfying the recurrence relation:

    T(n)=aT(nb)+f(n)T(n) = aT\left(\frac{n}{b}\right) + f(n)

    where a1a \ge 1, b>1b > 1 are constants, and f(n)f(n) is an asymptotically positive function. Let ccrit=logbac_{crit} = \log_b a. Then, we can determine the asymptotic behavior of T(n)T(n) as follows:

    • Case 1: If f(n)=O(nccritϵ)f(n) = O(n^{c_{crit} - \epsilon}) for some constant ϵ>0\epsilon > 0, then T(n)=Θ(nccrit)T(n) = \Theta(n^{c_{crit}}).

    (The cost is dominated by the leaves of the recursion tree).

    • Case 2: If f(n)=Θ(nccritlogkn)f(n) = \Theta(n^{c_{crit}} \log^k n) for some constant k0k \ge 0, then T(n)=Θ(nccritlogk+1n)T(n) = \Theta(n^{c_{crit}} \log^{k+1} n).

    (The cost is distributed evenly across the levels of the recursion tree).

    • Case 3: If f(n)=Ω(nccrit+ϵ)f(n) = \Omega(n^{c_{crit} + \epsilon}) for some constant ϵ>0\epsilon > 0, and if af(n/b)cf(n)a f(n/b) \le c f(n) for some constant c<1c < 1 and all sufficiently large nn (this is the regularity condition), then T(n)=Θ(f(n))T(n) = \Theta(f(n)).

    (The cost is dominated by the work done at the root of the recursion tree).

    Variables:

      • aa: The number of subproblems.

      • bb: The factor by which the input size is reduced for each subproblem.

      • f(n)f(n): The cost of dividing the problem and combining the results.


    When to use: For recurrences of the form T(n)=aT(n/b)+f(n)T(n) = aT(n/b) + f(n).

    Worked Example (Master Theorem):

    Problem: Analyze the recurrence T(n)=3T(n/4)+nlognT(n) = 3T(n/4) + n \log n.

    Solution:

    Step 1: Identify the parameters a,b,a, b, and f(n)f(n).
    From the recurrence, we have:
    a=3a = 3
    b=4b = 4
    f(n)=nlognf(n) = n \log n

    Step 2: Calculate the critical exponent ccrit=logbac_{crit} = \log_b a.

    ccrit=log430.792c_{crit} = \log_4 3 \approx 0.792

    Step 3: Compare f(n)f(n) with nccritn^{c_{crit}}.
    We are comparing f(n)=nlognf(n) = n \log n with nlog43n^{\log_4 3}.
    Clearly, nlognn \log n grows faster than n0.792n^{0.792}.
    Formally, f(n)=nlogn=Ω(nlog43+ϵ)f(n) = n \log n = \Omega(n^{\log_4 3 + \epsilon}) for some ϵ>0\epsilon > 0. For instance, we can choose ϵ=10.792=0.208\epsilon = 1 - 0.792 = 0.208, since nlogn=Ω(n1)n \log n = \Omega(n^1). This points us to Case 3.

    Step 4: Verify the regularity condition for Case 3.
    We must check if af(n/b)cf(n)a f(n/b) \le c f(n) for some c<1c < 1.

    af(n/b)=3(n4logn4)=34n(lognlog4)a f(n/b) = 3 \cdot \left(\frac{n}{4} \log \frac{n}{4}\right) = \frac{3}{4} n (\log n - \log 4)

    =34nlogn34nlog4= \frac{3}{4} n \log n - \frac{3}{4} n \log 4

    We need to show that 34nlogn34nlog4cnlogn\frac{3}{4} n \log n - \frac{3}{4} n \log 4 \le c \cdot n \log n for some c<1c < 1.
    For large nn, the nlognn \log n term dominates. We can see that the leading coefficient is 3/43/4, which is less than 1. So, we can choose c=3/4c = 3/4 (or any value between 3/43/4 and 1), and the condition holds for sufficiently large nn.

    Step 5: Apply the conclusion of Case 3.
    Since the conditions for Case 3 are met, the solution is T(n)=Θ(f(n))T(n) = \Theta(f(n)).

    Answer: T(n)=Θ(nlogn)\boxed{T(n) = \Theta(n \log n)}.

    ---

    ---

    4. Transformation of Variables (Substitution Method)

    Some recurrence relations do not fit the standard forms but can be transformed into one by a suitable change of variables. This is a powerful technique for unusual arguments like n\sqrt{n} or logn\log n.

    The general strategy is to define a new sequence S(k)S(k) in terms of T(n)T(n) by substituting nn with an expression involving kk, typically n=2kn=2^k.

    Worked Example (Transformation):

    Problem: Solve the recurrence T(n)=nT(n)+nT(n) = \sqrt{n}T(\sqrt{n}) + n for n>1n > 1, with T(2)=1T(2)=1.

    Solution:

    Step 1: Introduce a change of variables.
    The argument n\sqrt{n} suggests a substitution that simplifies repeated square roots. Let n=2mn = 2^m. This implies m=log2nm = \log_2 n.
    The recurrence becomes:

    T(2m)=(2m)1/2T((2m)1/2)+2mT(2^m) = (2^m)^{1/2} T((2^m)^{1/2}) + 2^m
    T(2m)=2m/2T(2m/2)+2mT(2^m) = 2^{m/2} T(2^{m/2}) + 2^m

    Step 2: Define a new sequence to simplify the relation further.
    Let S(m)=T(2m)S(m) = T(2^m). The recurrence in terms of SS is:

    S(m)=2m/2S(m/2)+2mS(m) = 2^{m/2} S(m/2) + 2^m

    This form is still not standard. Let us divide the entire equation by 2m2^m:

    S(m)2m=2m/2S(m/2)2m+2m2m\frac{S(m)}{2^m} = \frac{2^{m/2} S(m/2)}{2^m} + \frac{2^m}{2^m}
    S(m)2m=S(m/2)2m/2+1\frac{S(m)}{2^m} = \frac{S(m/2)}{2^{m/2}} + 1

    Step 3: Introduce a second change of variables.
    Let U(m)=S(m)2mU(m) = \frac{S(m)}{2^m}. The recurrence now becomes:

    U(m)=U(m/2)+1U(m) = U(m/2) + 1

    This is a very common recurrence relation.

    Step 4: Solve the simplified recurrence.
    By expansion (or Master Theorem), we can solve U(m)=U(m/2)+1U(m) = U(m/2) + 1.

    U(m)=U(m/4)+1+1=U(m/4)+2U(m) = U(m/4) + 1 + 1 = U(m/4) + 2

    U(m)=U(m/2k)+kU(m) = U(m/2^k) + k

    The recursion stops when m/2km/2^k is a small constant, say 11. Then m=2km=2^k, so k=log2mk=\log_2 m.
    Thus, U(m)=Θ(logm)U(m) = \Theta(\log m).

    Step 5: Substitute back to find the solution for T(n)T(n).
    First, substitute back for S(m)S(m):

    U(m)=S(m)2m    S(m)=2mU(m)=Θ(2mlogm)U(m) = \frac{S(m)}{2^m} \implies S(m) = 2^m \cdot U(m) = \Theta(2^m \log m)

    Next, substitute back for T(n)T(n):
    S(m)=T(2m)=T(n)S(m) = T(2^m) = T(n).
    m=log2nm = \log_2 n.
    So,

    T(n)=Θ(2log2nlog(log2n))=Θ(nloglogn)T(n) = \Theta(2^{\log_2 n} \log(\log_2 n)) = \Theta(n \log \log n)

    Answer: T(n)=Θ(nloglogn)\boxed{T(n) = \Theta(n \log \log n)}.

    ---

    Problem-Solving Strategies

    💡 GATE Strategy: Identify the Recurrence Type

    When faced with a recurrence relation in GATE, the first step is to classify it. This classification dictates the solution method.

    • Is it a linear relation with constant coefficients? (an=c1an1+a_n = c_1 a_{n-1} + \dots)

    - If yes, is it homogeneous (f(n)=0f(n)=0)? Use the characteristic equation method.
    - If no, is it non-homogeneous (f(n)0f(n) \neq 0)? Solve the homogeneous part first, then find a particular solution. Be wary of root collision.

    • Does it have the divide-and-conquer form? (T(n)=aT(n/b)+f(n)T(n) = aT(n/b) + f(n))

    - If yes, the Master Theorem is your primary tool. Quickly calculate logba\log_b a and compare f(n)f(n) with nlogban^{\log_b a} to determine the case.

    • Does it have an unusual argument? (T(n)T(\sqrt{n}), T(logn)T(\log n), etc.)
      - If yes, a transformation of variables is required. The most common substitution is n=2kn=2^k. The goal is to transform it into a known linear or divide-and-conquer form.

      • Is it defined piecewise or in a very strange way?

      - If none of the above apply, the method is likely pattern recognition. Calculate the first few terms of the sequence and look for a pattern. If options are provided (as in an MCQ), you can often test them against the base cases and the recurrence definition itself.

    ---

    Common Mistakes

    ⚠️ Avoid These Errors
      • Root Collision Oversight: In non-homogeneous problems, if f(n)f(n) has a form like CsnC \cdot s^n and ss is also a root of the characteristic equation, simply guessing AsnA \cdot s^n for the particular solution will fail.
    Correct Approach: Always solve the homogeneous part first. Check if the non-homogeneous term's form "collides" with any term in the homogeneous solution. If it does, multiply your guess for the particular solution by nn (or nmn^m if the root has multiplicity mm).
      • Misinterpreting Master Theorem Case 2: For the recurrence T(n)=aT(n/b)+f(n)T(n) = aT(n/b) + f(n), if f(n)=Θ(nlogba)f(n) = \Theta(n^{\log_b a}), concluding that T(n)=Θ(nlogba)T(n) = \Theta(n^{\log_b a}) is incorrect.
    Correct Approach: This scenario falls under the extended Case 2. When f(n)=Θ(nlogba)f(n) = \Theta(n^{\log_b a}), the solution is T(n)=Θ(nlogbalogn)T(n) = \Theta(n^{\log_b a} \log n). The extra logarithmic factor is crucial.
      • Algebraic Errors in Substitution: The transformation of variables method involves several layers of substitution. A small algebraic mistake at any step can lead to a completely incorrect final answer.
    Correct Approach: Be meticulous. Write down each substitution clearly (e.g., "Let n=2mn=2^m", "Let S(m)=T(2m)S(m) = T(2^m)"). Double-check your algebra as you simplify the transformed recurrence and when you substitute back.

    ---

    Practice Questions

    :::question type="MCQ" question="A sequence is defined by the recurrence relation an=2an1an2a_n = 2a_{n-1} - a_{n-2} for n2n \ge 2, with a0=3a_0 = 3 and a1=5a_1 = 5. What is the value of a10a_{10}?" options=["15","23","25","21"] answer="23" hint="This is a linear homogeneous recurrence. Find the characteristic equation and check for repeated roots." solution="
    Step 1: Form the characteristic equation.
    The recurrence is an2an1+an2=0a_n - 2a_{n-1} + a_{n-2} = 0.
    The characteristic equation is:

    r22r+1=0r^2 - 2r + 1 = 0

    Step 2: Find the roots.

    (r1)2=0\left(r-1\right)^2 = 0

    We have a repeated root r1=r2=1r_1 = r_2 = 1 with multiplicity 2.

    Step 3: Write the general solution for repeated roots.

    an=(α1+α2n)1n=α1+α2na_n = (\alpha_1 + \alpha_2 n) \cdot 1^n = \alpha_1 + \alpha_2 n

    This is an arithmetic progression.

    Step 4: Use initial conditions to find the constants.

    a0=3=α1+α2(0)    α1=3a_0 = 3 = \alpha_1 + \alpha_2(0) \implies \alpha_1 = 3

    a1=5=α1+α2(1)    5=3+α2    α2=2a_1 = 5 = \alpha_1 + \alpha_2(1) \implies 5 = 3 + \alpha_2 \implies \alpha_2 = 2

    Step 5: Write the closed-form solution.

    an=3+2na_n = 3 + 2n

    Step 6: Calculate a10a_{10}.

    a10=3+2(10)=23a_{10} = 3 + 2(10) = 23

    Answer: \boxed{23}
    "
    :::

    :::question type="NAT" question="Consider the recurrence relation T(n)=8T(n/2)+n3lognT(n) = 8T(n/2) + n^3 \log n. If the solution is given by T(n)=Θ(nklogpn)T(n) = \Theta(n^k \log^p n), what is the value of k+pk+p?" answer="5" hint="Use the Master Theorem. Identify a,b,a, b, and f(n)f(n) and determine which case applies." solution="
    Step 1: Identify parameters for the Master Theorem.
    a=8a = 8, b=2b = 2, f(n)=n3lognf(n) = n^3 \log n.

    Step 2: Calculate the critical exponent.

    ccrit=logba=log28=3c_{crit} = \log_b a = \log_2 8 = 3

    Step 3: Compare f(n)f(n) with nccritn^{c_{crit}}.
    We compare f(n)=n3lognf(n) = n^3 \log n with n3n^3.
    We see that f(n)=Θ(n3log1n)=Θ(nccritlog1n)f(n) = \Theta(n^3 \log^1 n) = \Theta(n^{c_{crit}} \log^1 n).

    Step 4: Apply the appropriate case of the Master Theorem.
    This fits the extended Case 2, where f(n)=Θ(nccritlogkn)f(n) = \Theta(n^{c_{crit}} \log^k n) with k=1k=1.
    The solution is T(n)=Θ(nccritlogk+1n)T(n) = \Theta(n^{c_{crit}} \log^{k+1} n).
    Substituting our values, we get:

    T(n)=Θ(n3log1+1n)=Θ(n3log2n)T(n) = \Theta(n^3 \log^{1+1} n) = \Theta(n^3 \log^2 n)

    Step 5: Determine the values of kk and pp.
    Comparing Θ(n3log2n)\Theta(n^3 \log^2 n) with the given form Θ(nklogpn)\Theta(n^k \log^p n), we have:
    k=3k = 3
    p=2p = 2

    Step 6: Calculate the final result.

    k+p=3+2=5k+p = 3+2 = 5

    Answer: \boxed{5}
    "
    :::

    :::question type="MCQ" question="What is the solution to the recurrence T(n)=3T(n1)+4nT(n) = 3T(n-1) + 4^n for n1n \ge 1, with T(0)=1T(0)=1?" options=["T(n)=4n+13n+1T(n) = 4^{n+1} - 3^{n+1}","T(n)=53n44nT(n) = 5 \cdot 3^n - 4 \cdot 4^n","T(n)=24n3nT(n) = 2 \cdot 4^n - 3^n","T(n)=4nT(n) = 4^n"] answer="T(n)=4n+13n+1T(n) = 4^{n+1} - 3^{n+1}" hint="This is a linear non-homogeneous recurrence. Find the homogeneous and particular solutions separately, then combine them using the initial condition." solution="
    Step 1: Solve the homogeneous part Tn(h)T_n^{(h)}.
    The characteristic equation for T(n)3T(n1)=0T(n) - 3T(n-1) = 0 is r3=0r-3=0, so r=3r=3.

    Tn(h)=α13nT_n^{(h)} = \alpha_1 \cdot 3^n

    Step 2: Find the particular solution Tn(p)T_n^{(p)}.
    The non-homogeneous term is f(n)=4nf(n) = 4^n. The base s=4s=4 is not a characteristic root.
    So, we guess a particular solution of the form Tn(p)=A4nT_n^{(p)} = A \cdot 4^n.
    Substitute this into the recurrence:

    A4n=3(A4n1)+4nA \cdot 4^n = 3(A \cdot 4^{n-1}) + 4^n

    Divide by 4n14^{n-1}:
    4A=3A+44A = 3A + 4

    A=4A = 4

    So, Tn(p)=44n=4n+1T_n^{(p)} = 4 \cdot 4^n = 4^{n+1}.

    Step 3: Write the general solution.

    T(n)=Tn(h)+Tn(p)=α13n+4n+1T(n) = T_n^{(h)} + T_n^{(p)} = \alpha_1 \cdot 3^n + 4^{n+1}

    Step 4: Use the initial condition T(0)=1T(0)=1 to find α1\alpha_1.

    T(0)=1=α130+40+1T(0) = 1 = \alpha_1 \cdot 3^0 + 4^{0+1}

    1=α1+41 = \alpha_1 + 4

    α1=3\alpha_1 = -3

    Step 5: State the final solution.

    T(n)=33n+4n+1=4n+13n+1T(n) = -3 \cdot 3^n + 4^{n+1} = 4^{n+1} - 3^{n+1}

    Answer: \boxed{T(n) = 4^{n+1} - 3^{n+1}}
    "
    :::

    :::question type="MSQ" question="A recurrence is defined as f(n)=f(n/3)+f(n/3)+nf(n) = f(\lfloor n/3 \rfloor) + f(\lceil n/3 \rceil) + n for n3n \ge 3, with f(1)=1,f(2)=2f(1)=1, f(2)=2. Which of the following statements are TRUE?" options=["f(n)=Ω(nlogn)f(n) = \Omega(n \log n)","f(n)=O(n2)f(n) = O(n^2)","f(n)=Θ(n)f(n) = \Theta(n)","f(n)=Θ(n(logn)2)f(n) = \Theta(n (\log n)^2)"] answer="A,B" hint="This recurrence is similar to Merge Sort's recurrence. Analyze its behavior using a recursion tree or by comparing it to a standard form like T(n)=2T(n/3)+nT(n) = 2T(n/3) + n." solution="
    Let's analyze the recurrence using a recursion tree.
    At the root, the cost is nn.
    At the next level, the sum of the non-recursive costs from the two subproblems is n/3+n/3=n\lfloor n/3 \rfloor + \lceil n/3 \rceil = n.
    This pattern continues down the tree. At each level, the total work done (excluding recursive calls) sums to nn.
    The depth of the recursion tree is log3n\log_3 n.
    The total cost is the sum of work at each level, which is (depth) ×\times (work per level).
    Total cost =log3nn=Θ(nlogn)= \log_3 n \cdot n = \Theta(n \log n).
    So, f(n)=Θ(nlogn)f(n) = \Theta(n \log n).

    Let's check the options based on f(n)=Θ(nlogn)f(n) = \Theta(n \log n):
    A. f(n)=Ω(nlogn)f(n) = \Omega(n \log n): True, since Θ(nlogn)\Theta(n \log n) implies f(n)f(n) is bounded below by nlognn \log n.
    B. f(n)=O(n2)f(n) = O(n^2): True, since nlognn \log n grows slower than n2n^2.
    C. f(n)=Θ(n)f(n) = \Theta(n): False, as nlognn \log n grows faster than nn.
    D. f(n)=Θ(n(logn)2)f(n) = \Theta(n (\log n)^2): False, as nlognn \log n grows slower than n(logn)2n (\log n)^2.

    Therefore, statements A and B are correct.
    Answer: \boxed{A,B}
    "
    :::

    ---

    Summary

    Key Takeaways for GATE

    • Master Linear Recurrences: The characteristic equation method is fundamental. Be able to solve both homogeneous and non-homogeneous cases, and pay extremely close attention to the special case where the non-homogeneous term's form matches a characteristic root.

    • Memorize the Master Theorem: For any recurrence of the form T(n)=aT(n/b)+f(n)T(n) = aT(n/b) + f(n), the Master Theorem is the fastest path to the solution. Know all three cases and the extended version of Case 2 (f(n)=Θ(nlogbalogkn)f(n) = \Theta(n^{\log_b a} \log^k n)).

    • Recognize When to Transform: If a recurrence contains unusual arguments like T(n)T(\sqrt{n}) or T(n/k)+T((k1)n/k)T(n/k) + T((k-1)n/k), standard methods will not apply directly. Your first instinct should be to try a substitution, most commonly n=2kn=2^k, to transform it into a more familiar structure.

      • Asymptotic Notation is Key: Most GATE questions ask for the asymptotic complexity (Θ,O,Ω\Theta, O, \Omega) rather than the exact closed-form solution. This often simplifies the problem, as you only need to identify the dominant term in the solution.

    ---

    What's Next?

    💡 Continue Learning

    This topic is deeply intertwined with several other critical areas in the GATE CS syllabus. Strengthening your understanding of recurrence relations will directly benefit your preparation in:

      • Design and Analysis of Algorithms: Recurrence relations are the primary mathematical tool for analyzing the time and space complexity of recursive algorithms. Understanding them is essential for topics like Divide and Conquer (e.g., Merge Sort, Quick Sort), Dynamic Programming, and recursive graph algorithms.
      • Asymptotic Analysis: The solutions to recurrence relations are expressed using asymptotic notations (Θ,O,Ω\Theta, O, \Omega). A firm grasp of how these notations relate to function growth is necessary to correctly interpret the results.
      • Generating Functions: While not as frequently tested as the methods discussed here, generating functions offer a more powerful and systematic, albeit more complex, approach to solving a wider variety of recurrence relations, especially those arising in combinatorics.

    ---

    💡 Moving Forward

    Now that you understand Recurrence Relations, let's explore Generating Functions which builds on these concepts.

    ---

    Part 3: Generating Functions

    Introduction

    Generating functions provide a powerful and elegant algebraic method for solving a wide variety of counting problems in combinatorics. At its core, a generating function is a formal power series whose coefficients encode a sequence of numbers. Instead of working with the sequence directly, we manipulate the compact, closed-form expression of the power series. This abstraction allows us to solve complex problems, such as finding the number of integer solutions to an equation with constraints or partitioning integers, by using standard algebraic operations like multiplication and differentiation.

    For the GATE examination, a foundational understanding of generating functions is valuable for certain advanced combinatorial problems. The primary focus is on translating a counting problem into its corresponding generating function, manipulating the function to find a specific coefficient, and interpreting that coefficient as the solution to the original problem. We will primarily concern ourselves with Ordinary Generating Functions (OGFs), which are used for problems involving combinations or selections of indistinguishable objects.

    📖 Ordinary Generating Function (OGF)

    For a given infinite sequence of numbers a0,a1,a2,a_0, a_1, a_2, \dots, the ordinary generating function (OGF) is the formal power series defined as:

    G(x)=n=0anxn=a0+a1x+a2x2+a3x3+G(x) = \sum_{n=0}^{\infty} a_n x^n = a_0 + a_1 x + a_2 x^2 + a_3 x^3 + \dots

    Here, ana_n is the coefficient of xnx^n, denoted as [xn]G(x)[x^n]G(x). The variable xx is treated as a formal symbol or a placeholder, not necessarily a number to be evaluated.

    ---

    ---

    ---

    Key Concepts

    1. Representing Sequences with Closed-Form Expressions

    The utility of generating functions arises from our ability to represent infinite power series with compact, finite expressions known as closed forms. The most fundamental of these is the geometric series.

    Consider the sequence (1,1,1,)(1, 1, 1, \dots), where an=1a_n = 1 for all n0n \ge 0. Its generating function is:

    G(x)=1+x+x2+x3+G(x) = 1 + x + x^2 + x^3 + \dots

    This is a geometric series with first term 1 and common ratio xx. For x<1|x| < 1, this series converges to a simple closed form. In the context of formal power series, we use this identity without concern for convergence.

    📐 Geometric Series Generating Function
    11x=n=0xn=1+x+x2+\frac{1}{1-x} = \sum_{n=0}^{\infty} x^n = 1 + x + x^2 + \dots

    Variables:

      • xx is a formal variable.


    When to use: This is the generating function for the constant sequence (1,1,1,)(1, 1, 1, \dots). It forms the basis for many other generating functions. For instance, the generating function for the sequence (1,c,c2,c3,)(1, c, c^2, c^3, \dots) is 11cx\frac{1}{1-cx}.

    Another crucial identity is the Binomial Theorem, particularly its generalized form.

    📐 Generalized Binomial Theorem
    (1+x)k=n=0(kn)xn(1+x)^k = \sum_{n=0}^{\infty} \binom{k}{n} x^n

    Where the binomial coefficient (kn)\binom{k}{n} is defined as:

    (kn)=k(k1)(kn+1)n!\binom{k}{n} = \frac{k(k-1)\dots(k-n+1)}{n!}

    Application: This is particularly useful for negative integer exponents. For instance, the coefficient of xnx^n in (1x)k(1-x)^{-k} is (kn)(1)n=(n+k1n)\binom{-k}{n}(-1)^n = \binom{n+k-1}{n}, which directly solves combinations with repetition problems.

    ---

    2. Application to Combinatorial Problems

    The primary application in the GATE context is solving problems that can be modeled as finding the number of non-negative integer solutions to an equation with constraints.

    Let us consider the problem of finding the number of integer solutions to the equation:

    e1+e2++ek=ne_1 + e_2 + \dots + e_k = n

    subject to certain constraints on each eie_i. We can model this problem by constructing a generating function where each variable eie_i corresponds to a polynomial factor. The exponents in each factor represent the allowed values for that variable. The number of solutions is then the coefficient of xnx^n in the product of these factors.

    Let Pi(x)P_i(x) be the polynomial (or series) representing the choices for eie_i. Then the overall generating function is:

    G(x)=P1(x)P2(x)Pk(x)G(x) = P_1(x) P_2(x) \dots P_k(x)

    The answer to the problem is [xn]G(x)[x^n]G(x).

    Worked Example:

    Problem: Find the number of non-negative integer solutions to the equation e1+e2+e3=5e_1 + e_2 + e_3 = 5.

    Solution:

    Step 1: Define the constraints and corresponding polynomials for each variable.
    For each variable eie_i, the allowed values are {0,1,2,3,}\{0, 1, 2, 3, \dots\}. The generating function for the choices of a single variable is therefore:

    P(x)=x0+x1+x2+x3+=11xP(x) = x^0 + x^1 + x^2 + x^3 + \dots = \frac{1}{1-x}

    Step 2: Construct the total generating function for the equation.
    Since there are three variables (e1,e2,e3e_1, e_2, e_3) with the same constraints, the total generating function G(x)G(x) is the product of their individual generating functions.

    G(x)=P(x)P(x)P(x)=(11x)3=(1x)3G(x) = P(x) \cdot P(x) \cdot P(x) = \left(\frac{1}{1-x}\right)^3 = (1-x)^{-3}

    Step 3: Find the coefficient of x5x^5 in the expansion of G(x)G(x).
    We need to find [x5](1x)3[x^5](1-x)^{-3}. Using the generalized binomial theorem, we know that the coefficient of xnx^n in (1x)k(1-x)^{-k} is (n+k1n)\binom{n+k-1}{n}.

    Here, n=5n=5 and k=3k=3.

    [x5](1x)3=(5+315)[x^5](1-x)^{-3} = \binom{5+3-1}{5}

    Step 4: Compute the final value.

    (75)=7!5!(75)!=7×62×1=21\binom{7}{5} = \frac{7!}{5!(7-5)!} = \frac{7 \times 6}{2 \times 1} = 21

    Answer: There are 21 non-negative integer solutions.

    ---

    Problem-Solving Strategies

    💡 GATE Strategy: Constraint to Polynomial Conversion

    When solving integer solution problems, quickly convert constraints on a variable into its polynomial factor.

      • No restriction (ei0e_i \ge 0): (1+x+x2+)=11x(1 + x + x^2 + \dots) = \frac{1}{1-x}
      • Lower bound (eice_i \ge c): (xc+xc+1+)=xc(1+x+)=xc1x(x^c + x^{c+1} + \dots) = x^c(1+x+\dots) = \frac{x^c}{1-x}
      • Upper bound (eice_i \le c): (1+x++xc)=1xc+11x(1 + x + \dots + x^c) = \frac{1-x^{c+1}}{1-x}
      • Even values (ei{0,2,4,}e_i \in \{0, 2, 4, \dots\}): (1+x2+x4+)=11x2(1 + x^2 + x^4 + \dots) = \frac{1}{1-x^2}
      • Odd values (ei{1,3,5,}e_i \in \{1, 3, 5, \dots\}): (x+x3+x5+)=x(1+x2+)=x1x2(x + x^3 + x^5 + \dots) = x(1+x^2+\dots) = \frac{x}{1-x^2}
    Multiplying these factors together gives the generating function for the entire problem. The solution is the coefficient of xnx^n.

    ---

    Practice Questions

    :::question type="MCQ" question="Which of the following expressions is the generating function for the number of ways to choose nn items from three distinct types, subject to the constraints that we must choose an even number of the first type, an odd number of the second type, and any number of the third type?" options=["x(1x2)2(1x)\frac{x}{(1-x^2)^2(1-x)}","x(1x2)(1x)2\frac{x}{(1-x^2)(1-x)^2}","1(1x2)(1x)\frac{1}{(1-x^2)(1-x)}","x(1x2)(1x)\frac{x}{(1-x^2)(1-x)}"] answer="x(1x2)2(1x)\frac{x}{(1-x^2)^2(1-x)}" hint="Construct the generating function for each constraint separately and then multiply them together." solution="
    Step 1: Determine the generating function for the first type (even number of items).
    The allowed number of items is {0,2,4,}\{0, 2, 4, \dots\}. The corresponding series is x0+x2+x4+x^0 + x^2 + x^4 + \dots.
    This is a geometric series with first term 1 and common ratio x2x^2.

    P1(x)=1+x2+x4+=11x2P_1(x) = 1 + x^2 + x^4 + \dots = \frac{1}{1-x^2}

    Step 2: Determine the generating function for the second type (odd number of items).
    The allowed number of items is {1,3,5,}\{1, 3, 5, \dots\}. The corresponding series is x1+x3+x5+x^1 + x^3 + x^5 + \dots.
    We can factor out xx to get x(1+x2+x4+)x(1 + x^2 + x^4 + \dots).

    P2(x)=x(1+x2+x4+)=x1x2P_2(x) = x(1 + x^2 + x^4 + \dots) = \frac{x}{1-x^2}

    Step 3: Determine the generating function for the third type (any number of items).
    The allowed number of items is {0,1,2,}\{0, 1, 2, \dots\}. The corresponding series is 1+x+x2+1 + x + x^2 + \dots.

    P3(x)=1+x+x2+=11xP_3(x) = 1 + x + x^2 + \dots = \frac{1}{1-x}

    Step 4: Multiply the individual generating functions to get the total generating function.
    The total generating function G(x)G(x) is the product P1(x)P2(x)P3(x)P_1(x)P_2(x)P_3(x).

    G(x)=(11x2)(x1x2)(11x)G(x) = \left(\frac{1}{1-x^2}\right) \left(\frac{x}{1-x^2}\right) \left(\frac{1}{1-x}\right)
    G(x)=x(1x2)2(1x)G(x) = \frac{x}{(1-x^2)^2(1-x)}

    Result: The correct expression is x(1x2)2(1x)\frac{x}{(1-x^2)^2(1-x)}.
    "
    :::

    :::question type="NAT" question="Find the number of ways to distribute 10 identical candies to 4 children such that each child receives at least one candy." answer="84" hint="This is equivalent to finding the number of positive integer solutions to c1+c2+c3+c4=10c_1+c_2+c_3+c_4=10. Model this with a generating function where each factor is of the form (x+x2+x3+)(x+x^2+x^3+\dots)." solution="
    Step 1: Formulate the problem as an integer solution equation.
    Let cic_i be the number of candies received by child ii. The problem is to find the number of integer solutions to:

    c1+c2+c3+c4=10c_1 + c_2 + c_3 + c_4 = 10

    with the constraint that ci1c_i \ge 1 for i=1,2,3,4i=1, 2, 3, 4.

    Step 2: Construct the generating function for a single child.
    Since each child must receive at least one candy, the choices for each cic_i are {1,2,3,}\{1, 2, 3, \dots\}. The generating function for one child is:

    P(x)=x1+x2+x3+=x(1+x+x2+)=x1xP(x) = x^1 + x^2 + x^3 + \dots = x(1 + x + x^2 + \dots) = \frac{x}{1-x}

    Step 3: Construct the total generating function for the problem.
    Since there are 4 children with identical constraints, the total generating function G(x)G(x) is [P(x)]4[P(x)]^4.

    G(x)=(x1x)4=x4(1x)4G(x) = \left(\frac{x}{1-x}\right)^4 = x^4 (1-x)^{-4}

    Step 4: Identify the required coefficient.
    We need to find the number of ways to get a total of 10 candies, which is the coefficient of x10x^{10} in G(x)G(x).

    [x10]G(x)=[x10]x4(1x)4[x^{10}] G(x) = [x^{10}] x^4 (1-x)^{-4}

    This is equivalent to finding the coefficient of x104=x6x^{10-4} = x^6 in the expansion of (1x)4(1-x)^{-4}.

    [x6](1x)4[x^6] (1-x)^{-4}

    Step 5: Apply the generalized binomial theorem.
    The coefficient of xnx^n in (1x)k(1-x)^{-k} is (n+k1n)\binom{n+k-1}{n}. Here, n=6n=6 and k=4k=4.

    [x6](1x)4=(6+416)=(96)[x^6] (1-x)^{-4} = \binom{6+4-1}{6} = \binom{9}{6}

    Step 6: Calculate the final value.

    (96)=(93)=9×8×73×2×1=3×4×7=84\binom{9}{6} = \binom{9}{3} = \frac{9 \times 8 \times 7}{3 \times 2 \times 1} = 3 \times 4 \times 7 = 84

    Answer: 84\boxed{84}
    "
    :::

    ---

    ---

    Summary

    Key Takeaways for GATE

    • A generating function G(x)=anxnG(x) = \sum a_n x^n is a formal power series that encodes a sequence (an)(a_n). The primary task is to find a specific coefficient [xn]G(x)[x^n]G(x).

    • The most crucial identity is the closed form for the geometric series: 11ax=n=0(ax)n\frac{1}{1-ax} = \sum_{n=0}^{\infty} (ax)^n.

    • Combinatorial problems involving integer solutions to equations of the form e1++ek=ne_1 + \dots + e_k = n can be solved by finding [xn][x^n] in the product of generating functions corresponding to the constraints on each eie_i.

    ---

    What's Next?

    💡 Continue Learning

    This topic connects to:

      • Combinatorics (Combinations with Repetition): Generating functions provide an alternative, more powerful method to solve stars and bars problems, especially when complex constraints are added. The coefficient [xn](1x)k[x^n](1-x)^{-k} is precisely the formula for combinations with repetition, (n+k1n)\binom{n+k-1}{n}.

      • Recurrence Relations: Generating functions are a standard technique for solving linear homogeneous and non-homogeneous recurrence relations. The recurrence is transformed into an algebraic equation for its generating function, which is then solved and expanded back into a series to find a closed-form for the nn-th term.


    Master these connections for comprehensive GATE preparation!

    Chapter Summary

    📖 Combinatorics - Key Takeaways

    In our study of combinatorics, we have explored the fundamental techniques for counting discrete structures. For success in the GATE examination, a firm grasp of the following core concepts is essential.

    • Fundamental Principles of Counting: We have established that the Sum Rule and Product Rule are the cornerstones of enumeration. The Sum Rule applies to disjoint choices, while the Product Rule applies to sequential, independent choices. Nearly all elementary counting problems can be deconstructed into applications of these two principles.

    • Permutations and Combinations: The distinction between ordered arrangements (permutations, denoted P(n,k)P(n, k)) and unordered selections (combinations, denoted C(n,k)C(n, k) or (nk)\binom{n}{k}) is of paramount importance. We have seen how to handle variations involving repetition, circular arrangements, and distributions of distinct versus identical items.

    • The Principle of Inclusion-Exclusion (PIE): For complex counting problems where direct application of the Sum Rule is difficult due to overlapping sets, the Principle of Inclusion-Exclusion provides a systematic method for correction. We have seen its utility in calculating the size of the union of several sets, particularly in problems involving properties such as divisibility.

    • Recurrence Relations: We have learned to model combinatorial problems by defining a sequence in terms of its preceding elements. The ability to formulate a recurrence relation from a problem description and solve it, especially linear homogeneous relations with constant coefficients using the characteristic equation method, is a critical skill.

    • Generating Functions: We introduced generating functions as a powerful algebraic tool for solving counting problems. By representing a sequence as the coefficients of a formal power series, we can translate complex combinatorial constraints into algebraic manipulations of these functions, thereby simplifying the problem of finding a specific term.

    • The Pigeonhole Principle: This principle, in both its simple and generalized forms, provides an elegant, non-constructive proof technique. It guarantees the existence of a certain property within a distribution without necessarily identifying the specific elements that have it.

    ---

    Chapter Review Questions

    :::question type="MCQ" question="How many integers between 1 and 1000 (inclusive) are divisible by neither 5 nor 7?" options=["686","714","286","700"] answer="A" hint="Use the Principle of Inclusion-Exclusion to find the number of integers that are divisible by at least one of the numbers, and subtract this from the total." solution="
    Let SS be the set of integers from 1 to 1000. We have S=1000|S| = 1000.
    Let AA be the set of integers in SS divisible by 5.
    Let BB be the set of integers in SS divisible by 7.

    We want to find the number of integers that are in neither AA nor BB, which is given by SAB|S| - |A \cup B|.
    Using the Principle of Inclusion-Exclusion, we know that AB=A+BAB|A \cup B| = |A| + |B| - |A \cap B|.

  • Calculate A|A|, the number of integers divisible by 5:

  • A=10005=200|A| = \left\lfloor \frac{1000}{5} \right\rfloor = 200

  • Calculate B|B|, the number of integers divisible by 7:

  • B=10007=142|B| = \left\lfloor \frac{1000}{7} \right\rfloor = 142

  • Calculate AB|A \cap B|, the number of integers divisible by both 5 and 7 (i.e., by their LCM, which is 35):

  • AB=100035=28|A \cap B| = \left\lfloor \frac{1000}{35} \right\rfloor = 28

  • Now, we find the number of integers divisible by at least one of them:

  • AB=200+14228=314|A \cup B| = 200 + 142 - 28 = 314

  • Finally, the number of integers divisible by neither 5 nor 7 is:

  • SAB=1000314=686|S| - |A \cup B| = 1000 - 314 = 686

    Thus, the correct option is A.
    "
    :::

    :::question type="NAT" question="Consider the recurrence relation an=5an16an2a_n = 5a_{n-1} - 6a_{n-2} with initial conditions a0=1a_0 = 1 and a1=4a_1 = 4. What is the value of a5a_5?" answer="454" hint="First, find the general solution to this linear homogeneous recurrence relation using its characteristic equation. Then, use the initial conditions to find the specific constants." solution="
    The given recurrence relation is a second-order linear homogeneous relation with constant coefficients:

    an5an1+6an2=0a_n - 5a_{n-1} + 6a_{n-2} = 0

  • Form the characteristic equation: We substitute an=rna_n = r^n into the relation to get:

  • r25r+6=0r^2 - 5r + 6 = 0

  • Find the roots of the characteristic equation: Factoring the quadratic equation, we get:

  • (r2)(r3)=0(r-2)(r-3) = 0

    The roots are r1=2r_1 = 2 and r2=3r_2 = 3.

  • Write the general solution: Since the roots are distinct, the general solution is of the form:

  • an=c1(r1)n+c2(r2)n=c12n+c23na_n = c_1 (r_1)^n + c_2 (r_2)^n = c_1 \cdot 2^n + c_2 \cdot 3^n

  • Use the initial conditions to find the constants c1c_1 and c2c_2:

  • For n=0n=0, we have a0=1a_0 = 1:
    c120+c230=1    c1+c2=1(Eq. 1)c_1 \cdot 2^0 + c_2 \cdot 3^0 = 1 \implies c_1 + c_2 = 1 \quad \text{(Eq. 1)}

    For n=1n=1, we have a1=4a_1 = 4:
    c121+c231=4    2c1+3c2=4(Eq. 2)c_1 \cdot 2^1 + c_2 \cdot 3^1 = 4 \implies 2c_1 + 3c_2 = 4 \quad \text{(Eq. 2)}

  • Solve the system of linear equations: Multiply Eq. 1 by 2 to get 2c1+2c2=22c_1 + 2c_2 = 2. Subtract this from Eq. 2: (2c1+3c2)(2c1+2c2)=42    c2=2(2c_1 + 3c_2) - (2c_1 + 2c_2) = 4 - 2 \implies c_2 = 2. Substitute c2=2c_2 = 2 back into Eq. 1: c1+2=1    c1=1c_1 + 2 = 1 \implies c_1 = -1.
  • Write the specific solution: The solution to the recurrence relation is:

  • an=(1)2n+23n=23n2na_n = (-1) \cdot 2^n + 2 \cdot 3^n = 2 \cdot 3^n - 2^n

  • Calculate a5a_5: Substitute n=5n=5 into the specific solution:

  • a5=23525=224332=48632=454a_5 = 2 \cdot 3^5 - 2^5 = 2 \cdot 243 - 32 = 486 - 32 = 454

    Alternatively, we can compute the terms iteratively:

    a2=5a16a0=5(4)6(1)=206=14a_2 = 5a_1 - 6a_0 = 5(4) - 6(1) = 20 - 6 = 14

    a3=5a26a1=5(14)6(4)=7024=46a_3 = 5a_2 - 6a_1 = 5(14) - 6(4) = 70 - 24 = 46

    a4=5a36a2=5(46)6(14)=23084=146a_4 = 5a_3 - 6a_2 = 5(46) - 6(14) = 230 - 84 = 146

    a5=5a46a3=5(146)6(46)=730276=454a_5 = 5a_4 - 6a_3 = 5(146) - 6(46) = 730 - 276 = 454

    "
    :::

    :::question type="MCQ" question="A committee of 4 people is to be formed from a group of 5 men and 4 women. In how many ways can this be done if the committee must contain at least one woman?" options=["126","120","121","125"] answer="C" hint="Use the complementary counting technique. Calculate the total number of ways to form the committee without any restrictions, and then subtract the single case that violates the condition." solution="
    The total number of people is 55 men +4+ 4 women =9= 9 people. The size of the committee to be formed is 4.

    We will use the principle of complementary counting, which is often simpler for problems involving 'at least one' constraints. The total number of ways to form the committee minus the number of ways that violate the condition gives the desired result.

  • Calculate the total number of ways to form a committee of 4 from 9 people, without any restrictions:

  • Total ways=(94)=9!4!(94)!=9×8×7×64×3×2×1=9×2×7=126\text{Total ways} = \binom{9}{4} = \frac{9!}{4!(9-4)!} = \frac{9 \times 8 \times 7 \times 6}{4 \times 3 \times 2 \times 1} = 9 \times 2 \times 7 = 126

  • Identify and calculate the number of ways for the case that violates the condition:

  • The condition is that the committee must contain 'at least one woman'. The only composition that violates this condition is a committee containing zero women (i.e., a committee composed entirely of men).

  • Calculate the number of ways to form a committee of 4 using only men:

  • We need to choose 4 men from the available 5 men.
    Ways with no women=(54)=5!4!1!=5\text{Ways with no women} = \binom{5}{4} = \frac{5!}{4!1!} = 5

  • Subtract the violating case from the total:

  • The number of ways to form a committee with at least one woman is:
    Valid ways=(Total ways)(Ways with no women)\text{Valid ways} = (\text{Total ways}) - (\text{Ways with no women})

    Valid ways=1265=121\text{Valid ways} = 126 - 5 = 121

    Thus, the correct option is C.
    "
    :::

    ---

    What's Next?

    💡 Continue Your GATE Journey

    Having completed Combinatorics, you have established a firm foundation for several advanced topics in the GATE syllabus. The principles of systematic counting and structured problem-solving developed in this chapter are indispensable tools.

    Connections to Previous and Future Learning:

    * This chapter is a direct application of the fundamentals of Set Theory. The Sum Rule, Product Rule, and Principle of Inclusion-Exclusion are formalizations of operations on the cardinality of sets.

    * The concepts mastered here are a direct prerequisite for the chapter on Probability. Calculating the probability of an event EE often requires us to first count the number of outcomes in the event space and the sample space, a task for which combinatorial techniques are essential.

    * In Graph Theory, many problems are combinatorial in nature. For example, counting the number of paths, cycles, spanning trees (using Cayley's formula or the matrix tree theorem), or valid graph colorings involves the application of combinatorial reasoning.

    * The analysis of algorithms in Data Structures and Algorithms heavily relies on recurrence relations to determine time complexity. The methods we have studied for solving recurrences are directly applicable to analyzing recursive algorithms such as binary search, merge sort, and quicksort.

    🎯 Key Points to Remember

    • Master the core concepts in Combinatorics before moving to advanced topics
    • Practice with previous year questions to understand exam patterns
    • Review short notes regularly for quick revision before exams

    Related Topics in Engineering Mathematics

    More Resources

    Why Choose MastersUp?

    🎯

    AI-Powered Plans

    Personalized study schedules based on your exam date and learning pace

    📚

    15,000+ Questions

    Verified questions with detailed solutions from past papers

    📊

    Smart Analytics

    Track your progress with subject-wise performance insights

    🔖

    Bookmark & Revise

    Save important questions for quick revision before exams

    Start Your Free Preparation →

    No credit card required • Free forever for basic features