Question
Consider the following two regular expressions over the alphabet :
The total number of strings of length less than or equal to 5, which are neither in nor in , is _________
Official answer and solution
- Official answer
- 44
- From
- Official GATE 2024 answer key
Solution
Subtract the number of strings of length in from the total number of binary strings of length .
-
Total binary strings of length :
-
Count strings in of length :
- : 1 string
- :
0,12 strings - :
00,11and01,104 strings - :
000,111and011,1004 strings - :
0000,1111and0111,10004 strings - :
00000,11111and01111,100004 strings
Total strings in of length is .
-
Strings in neither nor :
44
Forgetting to include the empty string (of length 0) or double-counting strings of length 1 (0 and 1) that belong to both and .
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 1 (CS1)
- Question
- 61 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.