GATE CS 2024 Set 2 — Question 62
NAT+2 / -0MediumRegular ExpressionsFinite Automata & Regular LanguagesTheory of Computation
Theory of Computation → Finite Automata & Regular Languages → Regular Expressions
Last updated
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 ___________
Correct answer
15 to 15
Solution
1.Analyze : The regular expression represents the set of all strings over that contain an odd number of 'a's.
- generates strings with exactly one 'a'.
- generates strings with an even number of 'a's (including zero).
- Concatenating them results in strings with 'a's, which is always odd.
3.Find : We need to count the number of strings of length that have an odd number of 'a's.
- For any length , the number of strings with an odd number of 'a's is exactly half of the total strings, i.e., .
- Length 0: Total strings = (the empty string ). Number of 'a's = 0 (even). Count = 0.
- Length 1: Count = (string is 'a').
- Length 2: Count = (strings are 'ab', 'ba').
- Length 3: Count = (strings are 'aaa', 'abb', 'bab', 'bba').
- Length 4: Count = (strings are 'aaab', 'aaba', 'abaa', 'baaa', 'abbb', 'babb', 'bbab', 'bbba').
More questions on Finite Automata & Regular Languages
2024 Set 2 Q22Which one of the following regular expressions is equivalent to the language accepted by the DFA…2024 Set 1 Q23Let be two regular languages and a language which is not regular. Which of the…2024 Set 2 Q41Let be the 5-state NFA with -transitions shown in the diagram below. [figure] Which…2024 Set 1 Q50Consider the 5-state DFA accepting the language shown below. For any…2024 Set 2 Q52Consider a context-free grammar with the following 3 rules.…
Practice GATE CS PYQs with adaptive difficulty
Timed practice, skill tracking, and AI explanations — free to start.
Start practicing free