Regular Expression · Theory of Computation
19 questions · asked in 14 of 27 years (2000–2026)
MCQ 16 · MSQ 1 · NAT 21-mark 15 · 2-mark 4
2000Questions per year2026
Questions 6–10 of 19
Which of the following regular expressions represent(s) the set of all binary numbers that are divisible by three? Assume that the string is divisible by three.
One or more options are correct.
Answer: (A), (B), (C)
The DFA for "value mod 3" has states 0, 1, 2 (start state and final state is 0). Reading bit takes state to state . So the moves are: state 0 on 0 stays at 0, on 1 goes to 1; state 1 on 0 goes to 2, on 1 goes to 0; state 2 on 0 goes to 1, on 1 stays at 2.
- (A) In state 0, "0" stays. "1" goes to state 1. From state 1, the part loops: "0" goes to state 2, any number of 1s stay at state 2, and "0" goes back to state 1. The last "1" returns to state 0. True
- (B) Same paths, written another way. In state 0: "0" stays, or "11" goes 0 to 1 to 0. Or "10" goes to state 2, then loops at state 2 ("1" stays, "00" goes 2 to 1 to 2), and "01" leaves state 2 and ends at state 0 (2 to 1 to 0). Those are all the ways back to state 0. True
- (C) where is the loop of option (A). So it is the same language as (A). True
- (D) It cannot give 1001 (= 9, divisible by 3), because every part starts with 0 or 11 and 1001 starts with 10. False
Answer: (A), (B), (C)
- (A) In state 0, "0" stays. "1" goes to state 1. From state 1, the part loops: "0" goes to state 2, any number of 1s stay at state 2, and "0" goes back to state 1. The last "1" returns to state 0. True
- (B) Same paths, written another way. In state 0: "0" stays, or "11" goes 0 to 1 to 0. Or "10" goes to state 2, then loops at state 2 ("1" stays, "00" goes 2 to 1 to 2), and "01" leaves state 2 and ends at state 0 (2 to 1 to 0). Those are all the ways back to state 0. True
- (C) where is the loop of option (A). So it is the same language as (A). True
- (D) It cannot give 1001 (= 9, divisible by 3), because every part starts with 0 or 11 and 1001 starts with 10. False
Answer: (A), (B), (C)
Which one of the following regular expressions represents the language: the set of all binary strings having two consecutive 0s and two consecutive 1s?
Answer: (B)
The string must have "00" somewhere and "11" somewhere, in either order. These two cannot overlap, so either "00" comes first or "11" does:
, which is option (B).
- (A) forces 00 and 11 to be adjacent (0011 or 1100). It misses 001011, which has both.
- (C) needs only one of them (it accepts 00, which has no 11).
- (D) forces them to sit at the very start and the very end. It misses 10011.
Answer: (B)
, which is option (B).
- (A) forces 00 and 11 to be adjacent (0011 or 1100). It misses 001011, which has both.
- (C) needs only one of them (it accepts 00, which has no 11).
- (D) forces them to sit at the very start and the very end. It misses 10011.
Answer: (B)
The length of the shortest string NOT in the language (over ={a,b}) of the following regular expression is _________.
a*b* (ba)* a*
a*b* (ba)* a*
Answer: 3
Every string of length 0, 1 and 2 is in the language: , a, b, aa, ab, bb (they come from a*b*), and ba (it comes from (ba)*).
Now take "bab". It starts with b, so the leading a* is empty. The b* part can take the first b only, because the next letter is a. Or b* can be empty.
- If b* takes "b", the rest is "ab". (ba)* must start with b, so it is empty, and a* takes "a" and leaves "b". This fails.
- If b* is empty, (ba)* can take "ba" and leaves "b", which a* cannot produce. Or (ba)* is empty and a* cannot start with b. This fails.
So bab is not in the language, and the shortest string not in it has length 3.
Answer: 3
Now take "bab". It starts with b, so the leading a* is empty. The b* part can take the first b only, because the next letter is a. Or b* can be empty.
- If b* takes "b", the rest is "ab". (ba)* must start with b, so it is empty, and a* takes "a" and leaves "b". This fails.
- If b* is empty, (ba)* can take "ba" and leaves "b", which a* cannot produce. Or (ba)* is empty and a* cannot start with b. This fails.
So bab is not in the language, and the shortest string not in it has length 3.
Answer: 3
Let L = {w (0 + 1)*|w has even number of 1s}, i.e. L is the set of all bit strings with even number of 1s. Which one of the regular expressions below represents L?
Answer: (B)
In , the part takes the leading 0s. Each group holds exactly two 1s with any number of 0s after each. So every string it makes has an even number of 1s, and any string with an even number of 1s can be cut into leading 0s and such groups. So (B) represents L.
Why the others fail:
- (A) makes only strings that are empty or end in 1, so it cannot make "0" or "110".
- (C) can put 0s only inside a group or at the two ends, so it cannot make "11011" (four 1s).
- (D) needs at least two 1s, so it cannot make "0" or the empty string.
Answer: (B)
Why the others fail:
- (A) makes only strings that are empty or end in 1, so it cannot make "0" or "110".
- (C) can put 0s only inside a group or at the two ends, so it cannot make "11011" (four 1s).
- (D) needs at least two 1s, so it cannot make "0" or the empty string.
Answer: (B)
Which one of the following languages over the alphabet {0,1} is described by the regular expression: (0+1)*0(0+1)*0(0+1)*?
Answer: (C)
The expression has two "0" symbols that must appear, in order, with any string of 0s and 1s before, between and after them. So it describes the strings with at least two 0's.
The other options do not match:
- (A) The string is accepted, but it does not have in it.
- (B) The string is accepted, but it has three 0's, which is more than two.
- (D) The set of strings that begin and end with 0 or 1 includes , but is not accepted since it has only one 0.
Answer: (C)
The other options do not match:
- (A) The string is accepted, but it does not have in it.
- (B) The string is accepted, but it has three 0's, which is more than two.
- (D) The set of strings that begin and end with 0 or 1 includes , but is not accepted since it has only one 0.
Answer: (C)
Keep practising