Question:

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

Show Hint

To count strings with specific patterns (like consecutive identical symbols), use the complement rule by first counting the total number of strings and then subtracting the number of strings that do not contain the desired pattern.
Updated On: Apr 4, 2025
Hide Solution
collegedunia
Verified By Collegedunia

Solution and Explanation

We are asked to find the number of ternary strings of length 5 that contain at least one occurrence of two consecutive symbols, specifically "aa", "bb", or "cc".

1. Total number of strings in \( S \):
The total number of ternary strings of length 5 is: \[ 3^5 = 243 \] because each position in the string can be filled with any of the three symbols \( a \), \( b \), or \( c \).

2. Strings without consecutive symbols:
Next, we need to subtract the number of strings that do not contain any consecutive identical symbols. If the string does not contain consecutive identical symbols, we have the following choices:
- The first character can be any of \( a \), \( b \), or \( c \).
- The second character must be different from the first.
- The third character must be different from the second, and so on.

So, the number of such strings is: \[ 3 \times 2 \times 2 \times 2 \times 2 = 3 \times 2^4 = 48 \] because the first character has 3 choices, and each subsequent character has 2 choices (to avoid repeating the previous character).

3. Strings with at least one pair of consecutive identical symbols:
The number of strings that contain at least one occurrence of two consecutive symbols is the complement of the number of strings without consecutive symbols. Thus, the number of strings with at least one consecutive pair is: \[ 243 - 48 = 195 \]
Thus, the number of such strings of length 5 is \( \boxed{195} \).
Was this answer helpful?
0
0

Questions Asked in GATE CS exam

View More Questions