Skip to content

GATE CS 2025 Set 1 Q20 — Combinatorics: Counting, Recurrence Relations, Generating Functions

Explain with AI
Let S\text{S} be the set of all ternary strings defined over the alphabet {a,b,c}\{a, b, c\}. Consider all strings in S\text{S} that contain at least one occurrence of two consecutive symbols, that is, "aa"\text{"aa"}, "bb"\text{"bb"} or "cc"\text{"cc"}. The number of such strings of length 55 that are possible is __________. (Answer in integer).
View worked solution

Answer: 195:195

To find the number of ternary strings of length 55 over the alphabet {a,b,c}\{a, b, c\} that contain at least one occurrence of consecutive identical symbols (i.e., "aa", "bb", or "cc"), we can use the principle of complementation.

Step 1: Calculate the total number of ternary strings of length 5

Since each position in a string of length 55 can be filled by any of the 33 symbols {a,b,c}\{a, b, c\}, the total number of ternary strings is: Total=35=243\text{Total} = 3^5 = 243

Step 2: Calculate the number of strings with no consecutive identical symbols

Let us construct a string of length 55 where no two adjacent symbols are the same:

  • The 1st1^{\text{st}} character can be any of the 33 symbols: 33 choices.
  • The 2nd2^{\text{nd}} character must be different from the 1st1^{\text{st}} character: 22 choices.
  • The 3rd3^{\text{rd}} character must be different from the 2nd2^{\text{nd}} character: 22 choices.
  • The 4th4^{\text{th}} character must be different from the 3rd3^{\text{rd}} character: 22 choices.
  • The 5th5^{\text{th}} character must be different from the 4th4^{\text{th}} character: 22 choices.
Using the product rule, the number of such strings is: Complement=3×2×2×2×2=3×24=48\text{Complement} = 3 \times 2 \times 2 \times 2 \times 2 = 3 \times 2^4 = 48

Step 3: Calculate the required number of strings

Subtracting the complement from the total number of strings: Required Strings=Total−Complement=243−48=195\text{Required Strings} = \text{Total} - \text{Complement} = 243 - 48 = 195

Free practice · Your answers on this page are not saved.

Published
Report a correction
Keep exploringMore Combinatorics: Counting, Recurrence Relations, Generating Functions questions