Introduction
15 questions over all of Phase 3, weighted towards classification and closure as in GATE.
Practice questions
- MCQ · 1 mark
L(S → aSbb | abb) is:
- { aⁿb²ⁿ : n ≥ 1 }
- { aⁿbⁿ }
- { a²ⁿbⁿ }
- a⁺b⁺
- MSQ · 2 marks
Which grammars are ambiguous?
- S → SS | a | b
- S → aSb | ab
- E → E + E | id
- S → aS | bS | ε
- NAT · 1 mark
Derivation steps in CNF for a string of length 12?
Write your answer before opening the key.
- MSQ · 1 mark
Which variables are useless in S → AB | a, A → a, B → BC, C → c?
- S
- A
- B
- C
- MCQ · 2 marks
Which language can be accepted by a DPDA by empty stack?
- a*
- { aⁿbⁿ : n ≥ 1 }
- { a, aa }
- (ab)*
- MSQ · 2 marks
Which are true?
- Regular ⊊ DCFL
- DCFL ⊊ CFL
- NPDA and DPDA accept the same languages
- Every DCFL has an unambiguous grammar
- MCQ · 1 mark
The PDA obtained from a CFG simulates:
- rightmost derivations
- leftmost derivations
- CYK
- shortest derivations
- MSQ · 2 marks
CFLs are closed under:
- reversal
- complement
- homomorphism
- intersection with regular sets
- MCQ · 2 marks
L₁ = { aⁿbⁿcᵐ }, L₂ = { aᵐbⁿcⁿ }. L₁ ∩ L₂ is:
- regular
- DCFL
- CFL, not DCFL
- not CFL
- MSQ · 1 mark
For arbitrary CFGs, which have algorithms?
- membership
- emptiness
- ambiguity
- equivalence
- NAT · 1 mark
CYK table cells for n = 7?
Write your answer before opening the key.
- MCQ · 2 marks
To show aⁿbⁿcⁿ is not a CFL, the key fact is:
- |vwx| ≤ p so the window misses one of the three blocks
- |xy| ≤ p
- v must be in the a’s
- w must be empty
- MSQ · 2 marks
Which are CFL but not DCFL?
- { wwᴿ }
- { aⁱbʲcᵏ : i = j or j = k }
- { aⁿbᵐcⁿ }
- complement of { ww }
- MCQ · 2 marks
{ aⁱbʲcᵏ : i < j < k } is:
- regular
- DCFL
- CFL, not DCFL
- not CFL
- MCQ · 1 mark
{ aⁿbⁿ : n ≤ 50 } is:
- regular
- DCFL, not regular
- CFL, not DCFL
- not CFL
Answer key
Reveal answers when you’re ready
- A — Two b’s per a, n ≥ 1.
- B: Ratio is 2.
- C: Backwards.
- D: Counts are tied.
- AC — Grouping choices.
- B: Unique derivations.
- D: Unique (right-linear, deterministic).
- 23 — 2n − 1.
- BCD — B → BC never finishes, so B is non-generating; deleting S → AB and B → BC leaves A and C unreachable. Result: S → a.
- A: S → a generates and S is the start.
- B — Prefix-free: no string of aⁿbⁿ (n ≥ 1) is a proper prefix of another.
- A: a prefix of aa.
- C: a prefix of aa.
- D: ε and ab are prefixes of abab.
- ABD — Standard hierarchy.
- C: NPDA is strictly stronger.
- B — Top of stack = leftmost unfinished symbol.
- A: No.
- C: Different algorithm.
- D: No.
- ACD — Complement fails.
- B: Not closed.
- D — aⁿbⁿcⁿ.
- A: No.
- B: No.
- C: Not even CFL.
- AB — Ambiguity and equivalence have none.
- C: No algorithm.
- D: No algorithm.
- 28 — 7·8/2.
- A — Window too short to touch a’s and c’s.
- B: Regular lemma.
- C: Not forced.
- D: Not forced.
- ABD — Guessing required.
- C: DCFL.
- D — Two comparisons at once.
- A: No.
- B: No.
- C: No.
- A — Finite.
- B: Finite languages are regular.
- C: No.
- D: No.