IAE Academy

GATE 2022 CS Q.12: solution and answer

GATE 2022 · CSQ.12 · 1 mark · MCQ

Which one of the following regular expressions correctly represents the language of the finite automaton given below?

GATE 2022 CS question 12: A DFA with three states.Tap to open full size
Figure from the GATE 2022 CS paper. It is part of the question.
Figure description

A DFA with three states. The start state q_0 (arrow entering from the left) is a non-accepting single circle. The two other states are accepting (double circles): q_1 (upper right) and q_2 (lower right). Transitions: q_0 --a--> q_1; q_1 --b--> q_0; q_1 has a self-loop labelled b; q_0 --b--> q_2; q_2 --a--> q_0; q_2 has a self-loop labelled a.

  1. (A)

  2. (B)

  3. (C)

  4. (D)

Answer and solution

ANSWER

The language of the automaton is , which is option (D).

Official answer: DSource: Official answer key, GATE 2022 CS (IIT Kharagpur)

  1. Read the automaton from the figure. is the start state and is not accepting; and are accepting. Transitions: , (loop), (return edge), , (loop), (return edge). Since has two -edges and has two -edges, the machine is non-deterministic.

  2. Since is not accepting, is rejected. Every accepted string ends in or . Split an accepted string at the last time the walk is in . Before that point the walk starts and ends at . After it, the walk never returns to and ends in or .

  3. Closed walks from back to are of two kinds. Through : read , then any number of loop symbols , then the return , giving . Through : read , then any number of loop symbols , then the return , giving . Any closed walk is a sequence of these, so the prefix is . This is the same as , because the order inside a union does not matter.

  4. The final part never returns to . It is either followed by loops, giving , or followed by loops, giving . So the final part is .

  5. Therefore , which is option (D).

  6. Check the other options on short strings. (A) needs at least , so it rejects , which the automaton accepts (). (C) accepts , because every factor can be empty, but is not accepting. (B) is a union of two expressions, and each one uses only one kind of closed walk. It rejects , which the automaton accepts: . (D) accepts through its prefix and final part. So only (D) is correct.

KEY IDEA

Split an accepted string at the last visit to the start state . The part before it is a sequence of closed loops through () or (). The part after it is a one-way trip to an accepting state ( or ).

WATCH OUT FOR

Treating the machine as deterministic and missing that and each have a loop and a return edge on the same symbol. Another mistake is choosing (B) or (C): (B) cannot mix visits to and before ending, and (C) accepts even though is not accepting.

From the GATE 2022 CS paper. Every question of this paper · Download the full paper · All 18 Finite automata questions, with notes

More Finite automata questions