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
Questions 11–15 of 19
Answer: (C)
- (A) Strings that have at least consecutive 's, with any number of 's and 's around them. matches, so it is not "exactly two".
- (B) Strings that have exactly two 's, and they must be consecutive. It misses , which has exactly two 1's.
- (C) Strings that have exactly two 's, which need not be consecutive, with any number of 0's before, between and after them.
- (D) Strings with any number of 's and 's, but at least two 's. matches.
Answer: (C)
Which one of the regular expressions given below defines the same language as defined by the regular expression R ?
Answer: (C)
We have the following NFA and its equivalent DFA. In the DFA, means the last symbol was a, means the last symbol was b, and means a double letter was seen.
Now remove and by state elimination. Their edges are not just deleted, they are written into the labels of the other edges:
- reads , so gets a self-loop . In the same way reads , so gets a self-loop .
- reaches by or by reading . reaches by or by reading .
So has the label , and loops on . The equivalent regular expression is , which is option (C).
The other options are wrong:
- (A) accepts (from then ), which has no or .
- (B) accepts every string, since and are both in .
- (D) needs at least one more symbol after the first double letter, so it rejects .
Answer: (C)
Which deterministic finite automaton accepts the language represented by the regular expression R?
Answer: (A)
Option A. From : a goes to , b goes to . Before any repeat, means the last symbol was a, and means it was b: goes to on b, and goes to on a. A repeat leaves this part: on a goes to (aa), and on b goes to (bb). From and , every move (a or b) goes to or , which are both final. So once aa or bb has appeared, the string is accepted whatever follows. A string with no aa and no bb alternates, ends in or , and is rejected. So A accepts exactly R. ( and behave the same, so they can be merged.)
Why the others fail:
- (B) is not a DFA: has two moves on a and none on b, and has two moves on b and none on a.
- (C) and (D) have the start state as a final state, so they accept the empty string, which has neither aa nor bb.
Note: in the paper's figure all four states of option (C) are labelled S3. They are four different states (the start state, the upper and lower states, and the final trap state).
Answer: (A)
Which of the following non-deterministic finite automata recognizes the language defined by the regular expression R? Edges labeled denote transitions on the empty string.
Answer: (A)
Option A. The loop on skips any prefix. Then a goes to or b goes to . is entered only on a and only on b. The only way into the final state is a from (so a just after a: aa) or b from (bb). Moving between and (b from , a from ) only alternates the symbols. Once in , the loop on a, b accepts any rest. So A accepts exactly the strings that contain aa or bb.
Why the others fail: in B, C and D, has a loop on a, b. The string "aba" has neither aa nor bb, but each of these NFAs accepts it: goes to on a, loops on b at , then goes to on a.
Answer: (A)
Answer: (A)
Let the states be and , taken in order from the start state, which is .
Start state: [Arden's theorem says if , then ][the term is there since this is the start state]
Next:
Then:
Finally:
The state is the final state, so the regular expression is . It is the set of strings whose third symbol from the end is a and whose last symbol is b.
The other options are wrong:
- (B) rejects , but the automaton accepts it ().
- (C) accepts , but the shortest accepted string has length 3.
- (D) accepts , but the start state is not final.
Answer: (A)
Keep practising