Skip to content
Official PYQ · 2007

GATE CS 2007 Q30 — Regular and Context-free Languages

Explain with AI

The language L={0i21i∣i≥0}L=\left\{0^i21^i \mid i \geq 0\right\} over the alphabet {0,1,2}\left\{0, 1, 2\right\} is:

Choose one option
View worked solution

Answer: B

To determine the class of the language L={0i21i∣i≥0}L = \{0^i 2 1^i \mid i \geq 0\} over the alphabet {0,1,2}\{0, 1, 2\}, let us analyze its properties:

  1. Not Regular: The language requires matching the number of 00s before the marker 22 with the number of 11s after the marker 22. Since a finite automaton has finite memory, it cannot keep track of an arbitrary count ii. Thus, LL is not a regular language (eliminating Option C).
  2. Deterministic Context-Free Language (DCFL): We can construct a Deterministic Pushdown Automaton (DPDA) to accept LL:
    • For every 00 read from the input, push it onto the stack.
    • When the marker 22 is encountered, transition to a new state without changing the stack. The marker 22 uniquely determines when to stop pushing and start popping.
    • For every 11 read, pop a 00 from the stack.
    • If the input ends precisely when the stack becomes empty (except for the initial stack symbol Z0Z_0), accept the string.
    Since there is no non-determinism involved at any step, LL is a deterministic CFL (eliminating Option D).
  3. Recursive: Every deterministic context-free language is also a context-free language, and all context-free languages are recursive (decidable). Thus, LL is recursive (eliminating Option A).

Therefore, the language LL is recursive and is a deterministic CFL.

Free practice · Your answers on this page are not saved.

Published
Report a correction
Keep exploringMore Regular and Context-free Languages questions