Let 𝑆 be the set of all ternary strings defined over the alphabet \(\{π‘Ž, 𝑏,…

2025

Let 𝑆 be the set of all ternary strings defined over the alphabet \(\{π‘Ž, 𝑏, 𝑐\}\). Consider all strings inΒ \(S\) 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)

Attempted by 53 students.

Show answer & explanation

Correct answer: 195

Answer: 195

Total number of ternary strings of length 5: 3^5 = 243

Count the strings that have no two consecutive symbols equal (i.e., avoid "aa", "bb", "cc") and subtract from the total:

  • Choose the first symbol: 3 choices.

  • For each of the remaining 4 positions, you must pick a symbol different from the previous one: 2 choices each, giving 2^4 = 16.

  • So the number of strings with no consecutive equal symbols is 3 * 2^4 = 48.

Therefore the number of length-5 strings that contain at least one occurrence of two consecutive identical symbols is 243 - 48 = 195.

Explore the full course: Gate Guidance By Sanchit Sir