Back to the 2025 paper

Module 2: Context-Free Languages (CFL) and PDA

20252m

Which of the following CFLs is deterministic?

(i) {anbna^n b^n}
(ii) Arithmetic expressions
(iii) Palindromes
(iv) {wwRww^R}

Worked SolutionAI Assisted

Answer

Correct Option: (i) {anbn}\{a^n b^n\}

Explanation

Deterministic CFL (DCFL): Accepted by DPDA (deterministic pushdown).

  • (i) {anbn}\{a^n b^n\}: DPDA can push aa's, then pop for bb's, deterministic (no choice). DCFL.
  • (ii) Arithmetic expressions (e.g., E→E+E∣E∗EE \rightarrow E+E \mid E*E) → inherently ambiguous, CFL but not deterministic (needs guessing).
  • (iii) Palindromes {wwR}\{ww^R\} → not deterministic (needs to guess middle). {w#wR}\{w\#w^R\} is DCFL, but plain palindromes is NPD A.
  • (iv) {wwR}\{ww^R\} similar to (iii) — not DCFL.

Hence only {anbn}\{a^n b^n\} is deterministic.

Final Answer

{anbn}\{a^n b^n\} is DCFL → Option (i).

Similar questions

Free AppAndroid App

Coursify Android App

Generate AI courses, take quick quizzes between classes, and master complex engineering concepts on the go.