chapter

    Combinatorics and Counting Notes for Gate Cs

    Combinatorics and Counting notes for GATE CS: 38 study cards covering concepts, formulas, shortcuts and exam traps, plus solved practice questions.

    Combinatorics and Counting notes

    Chapter Roadmap: Combinatorics and Counting

    Orientation Level 1

    Chapter Roadmap: Combinatorics and Counting

    Step 1 (Current)
    Stars and Bars & Integer Partitions
    Distributing identical items into distinct or identical bins.
    Step 2
    String Counting & Complementary Counting
    Arrangements with restrictions and total minus unwanted.
    Step 3
    Permutations & Order Constraints
    Assigning distinct tasks with priority or capacity rules.
    Step 4
    Subset & Binary Matrix Counting
    Counting subset pairs and matrices with parity constraints.
    Why this order? Stars and Bars teaches you how to handle indistinguishability, the hardest conceptual leap. The rest builds on it by adding order and distinctness.

    The Core Intuition: Stars and Bars

    Concept Level 1

    The Core Intuition: Stars and Bars

    Distributing identical items into distinct bins.

    Visual Model: 5 items, 3 bins
    Bin 1: 2    Bin 2: 0    Bin 3: 3
    The Logic
    • Total positions in sequence:
    • Choose positions for bars:
    • Or choose positions for stars:
    Key Condition: This standard formula assumes bins can be empty ().

    Worked Example: Ice Cream Scoops

    Worked Example Level 3

    Ice Cream Scoops

    A shop has 4 distinct flavors. One can purchase any number of scoops of any flavor. The order is inconsequential. How many ways to purchase 3 scoops?
    Mapping to Model
    Items (): 3 scoops (Identical count)
    Bins (): 4 flavors (Distinct)
    Constraint: (Can buy 0)
    Answer: 20

    35 more cards in this chapter

    Try a question

    Answer it here to see how it works. Nothing is recorded until you sign in.

    Question 1
    Level 1: Warm-up

    The formula for the number of non-negative integer solutions to the equation is:

    Question 2
    Level 1: Warm-up

    The number of non-negative integer solutions to the equation is given by which of the following?

    Question 3
    Level 1: Warm-up

    Which of the following formulas gives the number of ways to distribute identical items into distinct bins such that no bin is empty?

    Question 4
    Level 1: Warm-up

    In how many ways can 4 distinct books be arranged on a shelf such that book appears somewhere before book ?

    Question 5
    Level 1: Warm-up

    In how many ways can 5 distinct books be arranged on a shelf such that 3 specific books must appear in a fixed relative order (e.g., from left to right)?

    Question 6
    Level 1: Warm-up

    In a permutation of elements, what is the probability that two specific disjoint sets and , each of size , are completely separated (i.e., all elements of appear before all elements of , or vice versa)?

    Question 7
    Level 1: Warm-up

    Match the following distribution scenarios (I–IV) with their correct counting methods or formulas (P–S):

    Scenarios:

    I. Distributing 5 identical balls into 3 distinct bins (bins may be empty).

    II. Distributing 5 identical balls into 3 distinct bins (no bin may be empty).

    III. Distributing 5 distinct balls into 3 distinct bins.

    IV. Distributing 5 identical balls into 3 identical bins.

    Formulas/Methods:

    P.

    Q.

    R.

    S. List integer partitions of 5 into at most 3 parts

    Which of the following matching statements are correct?

    Question 8
    Level 1: Warm-up

    Match the following counting problems (I–IV) with their correct answers (P–S):

    Problems:

    I. Number of ways to choose 3 scoops of ice cream from 4 available flavors (order doesn't matter, repetition allowed).

    II. Number of ways to distribute 6 identical candies to 3 children such that each child gets at least one candy.

    III. Number of ways to place 4 distinct books on 3 distinct shelves.

    IV. Number of ways to distribute 6 identical balls into 3 identical boxes.

    Answers:

    P.

    Q.

    R.

    S. 7

    Which of the following matching statements are correct?

    Question 9
    Level 1: Warm-up
    To find the number of binary strings of length $5$ that contain at least one pair of consecutive '1's, which of the following expressions represents the correct method?
    Question 10
    Level 1: Warm-up

    For an binary matrix with an even number of 1s in every row and every column, the number of such matrices is .

    Which of the following values CANNOT be the number of such matrices for any positive integers ?

    Free preview ends here

    Login to view the complete notes

    Creating an account is free. You get the rest of this chapter, step-by-step solutions, and a study plan built around the topics you are actually weak at.

    Explore complete test series, official past papers, and chapter-wise study tools.

    Why MastersUp

    Personalised first. High quality throughout.

    Most platforms hand everyone the same content. Here the content moves with your performance, topic by topic.

    Built around you, not around a syllabus PDF

    Every answer you give moves your topic-level intelligence rate. The next question, the next revision card and tomorrow's plan all change with it.

    Revision that hits your weak spots

    We only revise topics you have actually attempted and are still below the safe bar on — never the same chapter on repeat.

    Questions calibrated to the real exam

    Each question carries a measured toughness. You are served a rung above your current level, so practice keeps stretching you.

    Notes written for recall, not for volume

    Full lesson cards for first study, curated short-note cards for the last mile — with derivations, traps and exam patterns marked.

    One place for everything

    Notes, chapter practice, previous-year questions, test series and full-length papers — all feeding one picture of your preparation.

    Honest progress

    No vanity streaks. Progress here means chapters mastered and accuracy that held up on harder questions.

    Unlock the whole course

    Full notes and short notes, the complete question bank with worked solutions, mock tests, full-length papers, and an adaptive plan that rebuilds itself as you improve.

    Combinatorics and Counting Notes for GATE CS

    Combinatorics and Counting notes for GATE CS: 38 study cards covering concepts, formulas, shortcuts and exam traps, plus solved practice questions.

    Chapter Roadmap: Combinatorics and Counting

    Orientation Level 1

    Chapter Roadmap: Combinatorics and Counting

    Step 1 (Current)
    Stars and Bars & Integer Partitions
    Distributing identical items into distinct or identical bins.
    Step 2
    String Counting & Complementary Counting
    Arrangements with restrictions and total minus unwanted.
    Step 3
    Permutations & Order Constraints
    Assigning distinct tasks with priority or capacity rules.
    Step 4
    Subset & Binary Matrix Counting
    Counting subset pairs and matrices with parity constraints.
    Why this order? Stars and Bars teaches you how to handle indistinguishability, the hardest conceptual leap. The rest builds on it by adding order and distinctness.

    The Core Intuition: Stars and Bars

    Concept Level 1

    The Core Intuition: Stars and Bars

    Distributing identical items into distinct bins.

    Visual Model: 5 items, 3 bins
    Bin 1: 2    Bin 2: 0    Bin 3: 3
    The Logic
    • Total positions in sequence:
    • Choose positions for bars:
    • Or choose positions for stars:
    Key Condition: This standard formula assumes bins can be empty ().

    Worked Example: Ice Cream Scoops

    Worked Example Level 3

    Ice Cream Scoops

    A shop has 4 distinct flavors. One can purchase any number of scoops of any flavor. The order is inconsequential. How many ways to purchase 3 scoops?
    Mapping to Model
    Items (): 3 scoops (Identical count)
    Bins (): 4 flavors (Distinct)
    Constraint: (Can buy 0)
    Answer: 20

    Variation: Positive Integer Solutions

    Concept Level 2

    Variation: Positive Integer Solutions

    Number of positive integer solutions ()
    Derivation
    1. Give 1 item to each of the bins.
    2. Remaining items: .
    3. Distribute items into bins where .
    4. Apply Case 1 formula: .
    Visual Gap Method
    gap gap
    stars create gaps. Choose gaps for bars.

    Combinatorics and Counting: Solved Questions with Step-by-Step Explanations (10 Problems)

    Question 1 · Engineering Mathematics MCQ

    The formula for the number of non-negative integer solutions to the equation is:

    1. A.

      inom{n+k-1}{k-1}

    2. B.

      inom{n-1}{k-1}

    3. C.

      inom{n+k}{k}

    4. D.

    Correct Answer:

    A

    Step-by-Step Solution

    Key idea: This is a direct formula recall question for the standard Stars and Bars method with non-negative integer solutions.

    Step 1: Recall the setup. We are distributing identical items into distinct bins, allowing empty bins.

    Step 2: Recall the formula. The number of ways is the number of ways to arrange stars and bars in total positions.

    Step 3: This is given by the combination .

    Answer: A

    Question 2 · Engineering Mathematics MCQ

    The number of non-negative integer solutions to the equation is given by which of the following?

    1. A.

      inom{10}{4}

    2. B.

      inom{13}{4}

    3. C.

      inom{12}{3}

    4. D.

      inom{13}{3}

    Correct Answer:

    D

    Step-by-Step Solution

    Key idea: This is a direct application of the Stars and Bars formula for non-negative integer solutions, recognizable by the equation format and the condition .

    Step 1: Identify the parameters. We are distributing identical items into distinct bins.

    Step 2: Recall the formula for non-negative solutions. The number of ways is .

    Step 3: Substitute the values. .

    Answer: D

    Question 3 · Engineering Mathematics MCQ

    Which of the following formulas gives the number of ways to distribute identical items into distinct bins such that no bin is empty?

    1. A.

      inom{n+k-1}{k-1}

    2. B.

      inom{n-1}{k-1}

    3. C.

      inom{n+k}{k}

    4. D.

      inom{n}{k}

    Correct Answer:

    B

    Step-by-Step Solution

    Key idea: This is a direct formula recall question for the Stars and Bars method, specifically for the case where no bin can be empty (positive integer solutions).

    Step 1: Recall the two main Stars and Bars formulas.

    For non-negative solutions (empty bins allowed): .

    For positive solutions (no empty bins): .

    Step 2: Match the condition in the question. "No bin is empty" means each bin must have at least one item, which corresponds to positive integer solutions.

    Step 3: Select the correct formula. The formula is .

    Answer: B

    Question 4 · Engineering Mathematics NAT

    In how many ways can 4 distinct books be arranged on a shelf such that book appears somewhere before book ?

    Correct Answer:

    12

    Step-by-Step Solution

    Key idea: Symmetry in permutations.

    Step 1: Calculate total unrestricted permutations of 4 distinct books.

    Total = .

    Step 2: Apply the relative order constraint.

    In any random permutation, either is before or is before .

    By symmetry, these two cases are equally likely.

    Step 3: Divide the total by 2.

    Ways = .

    Answer: 12

    Question 5 · Engineering Mathematics MCQ

    In how many ways can 5 distinct books be arranged on a shelf such that 3 specific books must appear in a fixed relative order (e.g., from left to right)?

    1. A.

    2. B.

    3. C.

    4. D.

    Correct Answer:

    B

    Step-by-Step Solution

    Key idea: This is a relative order constraint problem, recognizable by the phrase "fixed relative order".

    Step 1: Calculate the total unrestricted permutations of the 5 distinct books, which is .

    Step 2: Identify the constraint. 3 specific books must appear in one fixed relative order.

    Step 3: In the total permutations, these 3 books can be internally arranged in ways. Since only 1 of these internal orders is allowed, we divide the total by .

    Step 4: Calculate the result: .

    Answer: B

    Question 6 · Engineering Mathematics MCQ

    In a permutation of elements, what is the probability that two specific disjoint sets and , each of size , are completely separated (i.e., all elements of appear before all elements of , or vice versa)?

    1. A.

    2. B.

    3. C.

    4. D.

    Correct Answer:

    B

    Step-by-Step Solution

    Key idea: This is a direct recall of the separation probability formula for two disjoint sets of equal size.

    Step 1: Focus only on the elements belonging to .

    Step 2: In any random permutation, these elements can be internally ordered in ways.

    Step 3: Count the favorable internal orders. We need all of before all of , or all of before all of .

    Step 4: For "A before B", the first positions are and the last are . There are such orders.

    Step 5: By symmetry, "B before A" also gives orders. Total favorable = .

    Step 6: The probability is the ratio of favorable to total internal orders: .

    Answer: B

    Question 7 · Engineering Mathematics MSQ

    Match the following distribution scenarios (I–IV) with their correct counting methods or formulas (P–S):

    Scenarios:

    I. Distributing 5 identical balls into 3 distinct bins (bins may be empty).

    II. Distributing 5 identical balls into 3 distinct bins (no bin may be empty).

    III. Distributing 5 distinct balls into 3 distinct bins.

    IV. Distributing 5 identical balls into 3 identical bins.

    Formulas/Methods:

    P.

    Q.

    R.

    S. List integer partitions of 5 into at most 3 parts

    Which of the following matching statements are correct?

    1. A.

      Scenario I matches with P

    2. B.

      Scenario II matches with Q

    3. C.

      Scenario III matches with P

    4. D.

      Scenario IV matches with S

    Correct Answer:

    ["A","B","D"]

    Step-by-Step Solution

    Key idea: This is a decision matrix question. You must first check if items are identical or distinct, and then if bins are distinct or identical, before applying the correct formula.

    Step 1: Scenario I has identical items, distinct bins, empty allowed. Formula: . Matches P. (Option A is correct).

    Step 2: Scenario II has identical items, distinct bins, no empty bins. Formula: . Matches Q. (Option B is correct).

    Step 3: Scenario III has DISTINCT items. Stars and Bars does NOT apply. Each of the 5 distinct balls has 3 independent choices. Total = . Matches R, not P. (Option C is incorrect).

    Step 4: Scenario IV has identical items AND identical bins. Stars and Bars does NOT apply. We must list integer partitions. Matches S. (Option D is correct).

    Answer: A, B, D

    Question 8 · Engineering Mathematics MSQ

    Match the following counting problems (I–IV) with their correct answers (P–S):

    Problems:

    I. Number of ways to choose 3 scoops of ice cream from 4 available flavors (order doesn't matter, repetition allowed).

    II. Number of ways to distribute 6 identical candies to 3 children such that each child gets at least one candy.

    III. Number of ways to place 4 distinct books on 3 distinct shelves.

    IV. Number of ways to distribute 6 identical balls into 3 identical boxes.

    Answers:

    P.

    Q.

    R.

    S. 7

    Which of the following matching statements are correct?

    1. A.

      I matches with P

    2. B.

      II matches with Q

    3. C.

      III matches with inom{6}{2} = 15

    4. D.

      IV matches with S

    Correct Answer:

    ["A","B","D"]

    Step-by-Step Solution

    Key idea: This is a decision matrix question. You must first identify whether items are identical or distinct, and whether bins are identical or distinct, before applying the correct formula.

    Step 1: Analyze I. Items (scoops) are identical in count, bins (flavors) are distinct, empty allowed. This is a multiset coefficient: . Matches P. (Option A is correct).

    Step 2: Analyze II. Items (candies) are identical, bins (children) are distinct, no empty bins. Formula: . Matches Q. (Option B is correct).

    Step 3: Analyze III. Items (books) are DISTINCT. Stars and Bars does NOT apply. Each book independently chooses a shelf: . The option says , which is wrong. (Option C is incorrect).

    Step 4: Analyze IV. Items (balls) are identical, bins (boxes) are IDENTICAL. Stars and Bars does NOT apply. We must list partitions of 6 into at most 3 parts: 6+0+0, 5+1+0, 4+2+0, 4+1+1, 3+3+0, 3+2+1, 2+2+2. Total = 7. Matches S. (Option D is correct).

    Answer: A, B, D

    Question 9 · Engineering Mathematics MCQ
    To find the number of binary strings of length $5$ that contain at least one pair of consecutive '1's, which of the following expressions represents the correct method?
    1. A.

    2. B.

      (where is Fibonacci)

    3. C.

    4. D.

    Correct Answer:

    C

    Step-by-Step Solution

    Key idea: Complementary Counting. "At least one" is best solved by Total minus None. Step 1: Define the Total. Total binary strings of length 5 = . Step 2: Define the Complement. The complement of "at least one pair of consecutive 1s" is "NO pairs of consecutive 1s". Note: The option C uses the formula for "no adjacent identical characters" (). Let's verify if this matches "no consecutive 1s". Actually, "no consecutive 1s" is NOT the same as "no adjacent identical characters". Wait, let's look closer at the options provided in a Level 1 context. Let's re-evaluate standard L1 cards. Card c003 introduces the *concept* of complementary counting. The question asks for the *method*. Let's look at Option C: . Strings with no adjacent identical chars: (10101, 01010). Strings with NO consecutive 1s are more than just alternating strings (e.g., 00100 is valid). So C is technically incorrect for "no consecutive 1s". However, for a Level 1 question testing the *idea* of complementary counting from Card c003/c004, we often use the "No adjacent identical" case as the primary example because it has a clean closed form . Let's adjust the question to match the clean formula taught in L1 notes (Card c006/c008 summary). Revised Question Statement: "To find the number of ternary strings (alphabet ) of length $4$ that contain at least one instance of two identical adjacent characters (like 'aa'), which expression is correct?" Total = . Complement = Strings with NO identical adjacent characters. From Card c006: Count = . Result = . Let's map this to the options. Options: A) B) C) D) Answer: B. Step 1: Total strings = . Step 2: Complement is "no adjacent identical". Step 3: Count of complement = . Step 4: Subtract. This fits L1 perfectly.
    Question 10 · Engineering Mathematics MCQ

    For an binary matrix with an even number of 1s in every row and every column, the number of such matrices is .

    Which of the following values CANNOT be the number of such matrices for any positive integers ?

    1. A.

      16

    2. B.

      64

    3. C.

      256

    4. D.

      100

    Correct Answer:

    D

    Step-by-Step Solution

    Key idea: This is a "which is impossible" question about binary matrices with parity constraints. The count must be a power of 2.

    Step 1: The formula is . For any , the exponent is a non-negative integer.

    Step 2: Therefore, the count must be a power of 2:

    Step 3: Check each option:

    • → possible (e.g., : )
    • → possible (e.g., : )
    • → possible (e.g., : )
    • $100$ → NOT a power of 2 → impossible

    Step 4: By elimination, 100 cannot be the count → Option D

    Common trap (sign error): Computing incorrectly, e.g., or , which might give 100 for some . But the correct formula always gives a power of 2.

    More notes in this unit