GateAI
Regular Expressions and Finite Automata

GATE CSE 2012 · Q46

MCQ2 marksMedium

Time

Consider the set of strings on {0,1}\{0,1\} in which, *every substring of 3 symbols* has at most *two* zeros. For example, 001110 and 011001 are in the language, but 100010 is not. All strings of length less than 3 are also in the language. A partially completed DFA that accepts this language is shown below. The missing arcs in the DFA are

GATE CSE 2012 Q46 diagram

Select one answerSingle correct

Pick an option to check

Solution

Step-by-step verified solution

Official answer: D)

Regular Expressions and Finite Automata

The condition requires that no substring of length 33 contains three zeros (i.e., the substring 000000 is forbidden). Any string containing 000000 transitions to the dead/trap state qq.

In the DFA, each state tracks the 2-symbol suffix of the string processed so far:

  • From state 0000:

    • On receiving input 0: The 3-symbol suffix is 000 (forbidden), so it must transition to trap state qq.

    • On receiving input 1: The suffix becomes 01, so it transitions to state 0101.

  • From state 0101:

    • On receiving input 0: Suffix becomes 10 (transition already present in the DFA).

    • On receiving input 1: Suffix becomes 11, so it must transition to state 1111.

  • From state 1010:

    • On receiving input 0: Suffix becomes 00, so it must transition to state 0000.

    • On receiving input 1: Suffix becomes 01 (transition already present in the DFA).

  • From state 1111:

    • On receiving input 0: Suffix becomes 10, so it must transition to state 1010.

    • On receiving input 1: Suffix remains 11 (self-loop transition already present in the DFA).

Summarizing the missing transitions:

  • From 0000: input 1 goes to 0101, input 0 goes to qq

  • From 0101: input 1 goes to 1111

  • From 1010: input 0 goes to 0000

  • From 1111: input 0 goes to 1010

This transition table matches (D).

Try the question first, then check your work.

Think the official key or this write-up is wrong?

Report error or challenge

Examiner trap

The misconception this question tests

This Regular Expressions and Finite Automata previous year question is Q46 of the GATE CSE 2012 paper. Find more GATE CSE PYQs on Regular Expressions and Finite Automata in Theory of Computation, or browse all GATE CSE PYQs.

Free diagnostic

Where do you stand for GATE?

Take the 20-minute diagnostic: the 3 topics that cost you the most marks, and a rank range. Or sit 5 related Regular Expressions and Finite Automata PYQs now with no account.

One GATE CSE PYQ every morning

An official question by email at 7 AM IST, with a link to its verified solution. Unsubscribe in one click.

Regular Expressions and Finite Automata in GATE CSE

Regular Expressions and Finite Automata has 41 GATE CSE PYQs across 24 papers from 2011 to 2026. 10 of them are 2-mark MCQs like this one, and GATE CSE 2012 has 3.

How GATE tests Regular Expressions and Finite Automata

More from GATE CSE 2012

Share this solution

A plain-text card for WhatsApp or Telegram study groups.

GateAI solution cardGATE CSE 2012 · Q46 · MCQ

Consider the set of strings on {0,1} in which, *every substring of 3 symbols* has at most *two* zeros. For example, 001110 and 011001 are in the language, but 100010 is not. All strings of length less than 3 are also in the language. A partially completed DFA that accepts this language is shown below. The missing arcs in the DFA are

Topic-wise GATE CS PYQs with verified steps

Independent practice explanation verified by the GateAI team. GATE is conducted by the IITs; question text follows the official paper.