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

Budget AppAndroid App

Pocketly on Android

Log daily food, travel, and hostel expenses instantly. Set monthly spending limits and see where your money goes without complex spreadsheets.