Consider the following two regular expressions over the alphabet {0,1}: r = 0* + 1* s = 01* + 10* The total number of strings of length less than or equal to 5, which are neither in r nor in s, is …
Topic-wise GATE CS PYQs with verified steps
GATE CSE 2024 Set 1 · Q61
Time
Your answerNumerical answer
Solution
Official answer: 44
Regular Expressions and Finite AutomataLet .
Total number of strings of length : The total number of binary strings of length is .
**Strings in of length :**
Length 0: (1 string)
Length 1: (2 strings)
Length 2: (2 strings)
Length 3: (2 strings)
Length 4: (2 strings)
Length 5: (2 strings)
Total in of length is strings.
**Strings in of length :**
Length 1: $0, 1$ (already in $L(r)$)
Length 2: (2 new strings)
Length 3: (2 new strings)
Length 4: (2 new strings)
Length 5: (2 new strings)
Number of distinct strings in of length is strings.
Total strings in of length :
Strings of length neither in nor in :
Try the question first, then check your work.
Examiner trap
Find the total number of binary strings up to length 5, then count how many strings of each length match either or .
This Regular Expressions and Finite Automata previous year question is Q61 of the GATE CSE 2024 Set 1 paper. Find more GATE CSE PYQs on Regular Expressions and Finite Automata in Theory of Computation, or browse all GATE CSE PYQs.
Free diagnostic
Take the 20-minute diagnostic: the 3 topics that cost you the most marks, and a rank range. Or sit 5 related Regular Expressions and Finite Automata PYQs now with no account.
An official question by email at 7 AM IST, with a link to its verified solution. Unsubscribe in one click.
Regular Expressions and Finite Automata has 41 GATE CSE PYQs across 24 papers from 2011 to 2026. 6 of them are 2-mark NAT questions like this one, and GATE CSE 2024 Set 1 has 2.
How GATE tests Regular Expressions and Finite AutomataIndependent practice explanation verified by the GateAI team. GATE is conducted by the IITs; question text follows the official paper.