IAE Academy

GATE 2024 CS2 Q.22: solution and answer

GATE 2024 · CS2Q.22 · 1 mark · MCQ

Which one of the following regular expressions is equivalent to the language accepted by the DFA given below?

GATE 2024 CS2 question 22: A DFA with two states.Tap to open full size
Figure from the GATE 2024 CS2 paper. It is part of the question.
Figure description

A DFA with two states. The left state (call it q_0) is the start state (an arrow enters it from the left) and is not accepting. The right state (q_1) is accepting (double circle). q_0 has a self-loop labelled 0. q_1 has a self-loop labelled 0. There is an edge from q_0 to q_1 labelled 1 (upper arc) and an edge from q_1 back to q_0 labelled 1 (lower arc).

  1. (A)

  2. (B)

  3. (C)

  4. (D)

Answer and solution

ANSWER

Option (A):

Official answer: ASource: Official answer key, GATE 2024 CS2 (IISc Bengaluru)

  1. Read the DFA: the start state is (not accepting) and is the only accepting state. Both states have a self-loop on 0, and the symbol 1 moves and . So 0 never changes the state and 1 toggles it. The language is the set of strings over with an odd number of 1s.

  2. Derive the expression by state elimination. To go from to for the first time, read any number of 0s at and then a 1. This gives the prefix .

  3. Every way of leaving and returning to is one of two kinds. Either read a 0 (the self-loop), or read a 1 to , then at , then a 1 back to , which is . So the loop part is .

  4. Therefore , which is option (A).

  5. Check the other options with short strings. The string has one 1 and is accepted. (B) cannot generate , since every 1 in it comes in a block of three 1s or none. (D) must begin with 0, so it cannot generate . (C) cannot generate , which has three 1s and is accepted. After the first 1, every block must start with 0, and the trailing part is only 0s. Also test (A) on , which has three 1s and is accepted: with gives , so (A) generates it.

KEY IDEA

Each 0 leaves the state unchanged and each 1 toggles it, so the DFA accepts exactly the strings with an odd number of 1s. State elimination gives to reach the accepting state for the first time, followed by a loop of or .

WATCH OUT FOR

Forgetting that the loop at is inside the block, which gives rather than or . Another mistake is picking an expression that cannot produce the single string , or one that forces a 0 after the first 1 (as in option C), which wrongly rejects strings such as .

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

More Finite automata questions