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
    To find the number of binary strings of length that contain at least one pair of consecutive '1's, which of the following expressions represents the correct method?
    Question 8
    Level 1: Warm-up

    In the Stars and Bars method, what do the "bars" represent when distributing identical items into distinct bins?

    Question 9
    Level 1: Warm-up

    The number of positive integer solutions to the equation is:

    Question 10
    Level 1: Warm-up

    Which of the following scenarios requires the use of Integer Partitions?

    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.

    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 MCQ
    To find the number of binary strings of length 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 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 8 · Engineering Mathematics MCQ

    In the Stars and Bars method, what do the "bars" represent when distributing identical items into distinct bins?

    1. A.

      The identical items being distributed

    2. B.

      The distinct bins receiving the items

    3. C.

      The dividers separating the bins

    4. D.

      The number of empty bins

    Correct Answer:

    C

    Step-by-Step Solution

    Key idea: This is a conceptual question about the Stars and Bars model, recognizable because it asks about the meaning of the components in the method.

    Step 1: Recall the setup of the Stars and Bars method. We use it to distribute identical items into distinct bins.

    Step 2: Identify the symbols. The "stars" represent the identical items being distributed. The "bars" act as dividers to separate the stars into different groups (bins).

    Step 3: For distinct bins, we need bars to create sections.

    Answer: C

    Question 9 · Engineering Mathematics NAT

    The number of positive integer solutions to the equation is:

    Correct Answer:

    364

    Step-by-Step Solution

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

    Step 1: Identify the parameters. We are distributing identical items into distinct bins, with each bin getting at least one item.

    Step 2: Recall the formula for positive solutions. The number of ways is .

    Step 3: Substitute the values. .

    Step 4: Calculate the combination. .

    Answer: 364

    Question 10 · Engineering Mathematics MCQ

    Which of the following scenarios requires the use of Integer Partitions?

    1. A.

      Distributing 5 distinct books to 3 distinct students

    2. B.

      Distributing 5 identical apples to 3 distinct students

    3. C.

      Distributing 5 identical apples to 3 identical students (bins)

    4. D.

      Arranging 5 distinct books on a shelf

    Correct Answer:

    C

    Step-by-Step Solution

    Key idea: This question tests the recognition of when to use Integer Partitions versus Stars and Bars, recognizable by the identical nature of both the items and the bins.

    Step 1: Analyze the items. Are they distinct or identical? Integer partitions apply to identical items.

    Step 2: Analyze the bins. Are they distinct or identical? Integer partitions apply when the bins are identical (order of groups doesn't matter).

    Step 3: Evaluate the options. Option C describes identical items (apples) into identical bins (students treated as identical groups). This requires listing the partitions of 5 into at most 3 parts.

    Answer: C

    More notes in this unit