GATE Computer ScienceHardGATE CS (PYQ pattern)
Consider I. {aⁿbᵐcⁿdᵐ | n, m ≥ 1}, II. {aⁿbᵐcᵐdⁿ | n, m ≥ 1}, III. {wwᴿ | w ∈ {a,b}*}, IV. {ww | w ∈ {a,b}*}. Which of these languages are context-free?
- A. I and II only
- B. II and III only
- C. III and IV only
- D. I, II and III only
Correct answer: B. II and III only
II is nested (aⁿ ... dⁿ around bᵐcᵐ) and III is a palindrome language, so both are accepted by PDAs. I and IV need crossing (non-nested) comparisons of two unbounded counts or of w with itself, which a single stack cannot do, so they are not context-free.
More Theory of Computation questions
- Which regular expression over {0,1} denotes exactly the set of strings that do not contain two consecutive 1s?
- Which of the following problems are decidable? I. Is L(G) empty for a given CFG G? II. Is L(G1) ∩ L(G2) empty for given CFGs G1 and G2?…
- Let L = { w ∈ {a, b} : (number of a's − number of b's) is divisible by 4 }. How many states does the minimal DFA for L have?
- A grammar G in Chomsky Normal Form (no ε-production) generates a string w of length 9. How many derivation steps does any derivation of w…
- Let L = { w ∈ {a, b} : w contains at most 3 a's and at least 2 b's }. How many states does the minimal complete DFA for L have?
- Let #ab(w) and #ba(w) be the numbers of occurrences of the substrings ab and ba in w ∈ {a, b}. Which one of the following languages is…