Question
Let be the set of all ternary strings defined over the alphabet . Consider all strings in that contain at least one occurrence of two consecutive symbols, that is, "aa", "bb" or "cc". The number of such strings of length 5 that are possible is _______. (Answer in integer)
Official answer and solution
- Official answer
- 195
- From
- Official GATE 2025 answer key
Solution
Subtract the number of length-5 ternary strings with no two adjacent identical characters from the total number of length-5 ternary strings.
- Total ternary strings of length 5: Since each of the positions has choices ( or ), there are strings in total.
- Strings with NO two consecutive identical symbols:
- Position 1 can be any of the symbols.
- Each of positions 2, 3, 4, and 5 can be any of the symbols different from the immediately preceding symbol.
- Count .
- Strings with at least one occurrence of
aa,bb, orcc:
195
The answer is the one in the official GATE answer key. The solution is this site's own explanation.
Source
- Paper
- GATE 2025 Computer Science and Information Technology - Session 1 (CS1)
- Question
- 30 of 65
- Section
- Computer Science and Information Technology
Report an error in this question
GATE questions are the work of the organising institutes. This site is independent and is not affiliated with them.