GATE Computer ScienceHardGATE CS (PYQ pattern)
Consider L = { aⁿbⁿ : n ≥ 0 } ∪ { aⁿb²ⁿ : n ≥ 0 }. Which classification is correct?
- A. Regular
- B. Deterministic context-free
- C. Context-free, not deterministic
- D. Not context-free
Correct answer: C. Context-free, not deterministic
It is a union of two CFLs, so context-free. A DPDA would have to decide after the a's whether to expect n or 2n b's, which it cannot; the language is the standard example of a CFL that is not a DCFL.
More Theory of Computation questions
- Over the alphabet {a, b, c}, what is the status of the complement of { aⁿbⁿcⁿ : n ≥ 0 }?
- Consider the language L of strings over {a, b} that contain both abab and bb as substrings, have na ≡ 1 (mod 3) and have an even number of…
- What is the length of the shortest string over {a, b} that has length divisible by 4, contains both aab and bba, has an odd number of b's…
- L₁ is the set of strings over {a, b} containing aa and L₂ the set containing bb. How many strings of length at most 6 lie in the symmetric…
- Let h be the homomorphism h(a) = 0, h(b) = 01. How many distinct strings of length exactly 10 are in the image h({a, b})?
- Which of the following decision problems can be solved by an algorithm that always halts?