Skip to content
GATEiit

GATE CSE 2025 Session 1 Q30: Ternary strings of length 5 with a repeated adjacent symbol

Question

Let SS be the set of all ternary strings defined over the alphabet {a,b,c}\{a, b, c\}. Consider all strings in SS 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)

Try it: numerical answer: type the value

Numerical answer. No negative marking.
Show answer and explanation

Answer: 195 (official GATE 2025 final answer key)

Concept used: Complementary counting: count strings with no two equal adjacent symbols and subtract.

First step: Strings with no equal neighbours: 3 choices for the first symbol and 2 for each later one, i.e. 3⋅243 \cdot 2^4; subtract from 353^5.

Full step-by-step solution

Detailed working, common mistakes and linked mock tests will be available with a free GATEiit account. Log-in is coming soon.

Share this question

WhatsAppDownload image

Source: official GATE 2025 Session 1 CS question paper and final answer key, organised by IIT Roorkee. Question paper · Answer key