Question
Let be the language represented by the regular expression and , where denotes the length of string . The number of strings in which are also in is ___________
Official answer and solution
- Official answer
- 15
- From
- Official GATE 2024 answer key
Solution
Observe that is the set of all strings over with an odd number of 's, and count such strings of length .
The regular expression matches all strings over that contain an odd number of 's ( occurrences of ).
For each string length in :
- : has 's ( strings).
- : string (
a). - : strings (
ab,ba). - : strings ().
- : strings ().
Total number of strings in .
15
The answer is the one in the official GATE answer key. The solution is this site's own explanation.
Source
- Paper
- GATE 2024 Computer Science and Information Technology - Set 2 (CS2)
- Question
- 62 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.