IAE Academy

GATE 2024 CS2 Q.41: solution and answer

GATE 2024 · CS2Q.41 · 2 marks · MCQ

Let be the 5-state NFA with -transitions shown in the diagram below. Which one of the following regular expressions represents the language accepted by ?

GATE 2024 CS2 question 41: States 1 to 5.Tap to open full size
Figure from the GATE 2024 CS2 paper. It is part of the question.
Figure description

States 1 to 5. State 1 is the start state (arrow entering from the left). States 2 and 5 are accepting (double circles). Transitions: 1 --ε--> 2; 1 --ε--> 4; 2 --0--> 3; 3 --0--> 2; 3 --ε--> 5; 4 --1--> 5; 5 --1--> 4.

  1. (A)

  2. (B)

  3. (C)

  4. (D)

Answer and solution

ANSWER

Option (B): .

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

  1. From the start state 1, the -moves lead to state 2 or state 4, so is the union of the strings accepted from 2 and from 4.

  2. Branch through 2: the states 2 and 3 form a loop on (). The strings that bring back to state 2 are . State 2 is accepting, so is accepted.

  3. The strings that reach state 3 from 2 are . From 3 the -move goes to state 5, which is accepting. At 5 the loop reads , so can read any and still be in 5. This branch adds .

  4. Branch through 4: reading takes 4 to 5, and then keeps in 5. This gives . State 4 is not accepting, so a string that ends in 4 is rejected; in particular this branch does not accept .

  5. Combine: .

  6. Rewrite using . Taking zero repetitions of gives , which is already in . So adding to changes nothing, and . This is option B.

  7. Check the other options with test strings. A rejects , but accepts it ( on , then goes ). C accepts (take as , then ), but does not accept it ( ends in the non-accepting state 4). D rejects , but accepts because on an -move.

KEY IDEA

Split the NFA at the start state into the branch through state 2 (the 0-loop, then into state 5 and the 11-loop) and the branch through state 4 (which needs one 1 to reach state 5). Then merge the two pieces and of the first branch into .

WATCH OUT FOR

Forgetting the -move from state 3 to state 5, which gives the strings , or treating state 4 as accepting. The first mistake leads to option A. The second mistake would wrongly accept strings such as , as in option C.

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