CS Atlas GATE 2027
TOC course
0 / 91 complete

TOC/Phase 3 · CFG, PDA & Context-Free Languages

Checkpoint CP3 · Item 64 of 91

CFG, PDA & context-free languages

Read at your own pace. Try the questions before opening the answers.

On this page

Introduction

15 questions over all of Phase 3, weighted towards classification and closure as in GATE.

Practice questions

  1. MCQ · 1 mark

    L(S → aSbb | abb) is:

    1. { aⁿb²ⁿ : n ≥ 1 }
    2. { aⁿbⁿ }
    3. { a²ⁿbⁿ }
    4. a⁺b⁺
  2. MSQ · 2 marks

    Which grammars are ambiguous?

    1. S → SS | a | b
    2. S → aSb | ab
    3. E → E + E | id
    4. S → aS | bS | ε
  3. NAT · 1 mark

    Derivation steps in CNF for a string of length 12?

    Write your answer before opening the key.

  4. MSQ · 1 mark

    Which variables are useless in S → AB | a, A → a, B → BC, C → c?

    1. S
    2. A
    3. B
    4. C
  5. MCQ · 2 marks

    Which language can be accepted by a DPDA by empty stack?

    1. a*
    2. { aⁿbⁿ : n ≥ 1 }
    3. { a, aa }
    4. (ab)*
  6. MSQ · 2 marks

    Which are true?

    1. Regular ⊊ DCFL
    2. DCFL ⊊ CFL
    3. NPDA and DPDA accept the same languages
    4. Every DCFL has an unambiguous grammar
  7. MCQ · 1 mark

    The PDA obtained from a CFG simulates:

    1. rightmost derivations
    2. leftmost derivations
    3. CYK
    4. shortest derivations
  8. MSQ · 2 marks

    CFLs are closed under:

    1. reversal
    2. complement
    3. homomorphism
    4. intersection with regular sets
  9. MCQ · 2 marks

    L₁ = { aⁿbⁿcᵐ }, L₂ = { aᵐbⁿcⁿ }. L₁ ∩ L₂ is:

    1. regular
    2. DCFL
    3. CFL, not DCFL
    4. not CFL
  10. MSQ · 1 mark

    For arbitrary CFGs, which have algorithms?

    1. membership
    2. emptiness
    3. ambiguity
    4. equivalence
  11. NAT · 1 mark

    CYK table cells for n = 7?

    Write your answer before opening the key.

  12. MCQ · 2 marks

    To show aⁿbⁿcⁿ is not a CFL, the key fact is:

    1. |vwx| ≤ p so the window misses one of the three blocks
    2. |xy| ≤ p
    3. v must be in the a’s
    4. w must be empty
  13. MSQ · 2 marks

    Which are CFL but not DCFL?

    1. { wwᴿ }
    2. { aⁱbʲcᵏ : i = j or j = k }
    3. { aⁿbᵐcⁿ }
    4. complement of { ww }
  14. MCQ · 2 marks

    { aⁱbʲcᵏ : i < j < k } is:

    1. regular
    2. DCFL
    3. CFL, not DCFL
    4. not CFL
  15. MCQ · 1 mark

    { aⁿbⁿ : n ≤ 50 } is:

    1. regular
    2. DCFL, not regular
    3. CFL, not DCFL
    4. not CFL

Answer key

Reveal answers when you’re ready
  1. A — Two b’s per a, n ≥ 1.
    • B: Ratio is 2.
    • C: Backwards.
    • D: Counts are tied.

    Review lesson 3.1.2

  2. AC — Grouping choices.
    • B: Unique derivations.
    • D: Unique (right-linear, deterministic).

    Review lesson 3.1.3

  3. 23 — 2n − 1.

    Review lesson 3.2.2

  4. 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.

    Review lesson 3.2.1

  5. 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.

    Review lesson 3.3.2

  6. ABD — Standard hierarchy.
    • C: NPDA is strictly stronger.

    Review lesson 3.3.3

  7. B — Top of stack = leftmost unfinished symbol.
    • A: No.
    • C: Different algorithm.
    • D: No.

    Review lesson 3.3.4

  8. ACD — Complement fails.
    • B: Not closed.

    Review lesson 3.4.1

  9. D — aⁿbⁿcⁿ.
    • A: No.
    • B: No.
    • C: Not even CFL.

    Review lesson 3.4.1

  10. AB — Ambiguity and equivalence have none.
    • C: No algorithm.
    • D: No algorithm.

    Review lesson 3.4.2

  11. 28 — 7·8/2.

    Review lesson 3.4.2

  12. A — Window too short to touch a’s and c’s.
    • B: Regular lemma.
    • C: Not forced.
    • D: Not forced.

    Review lesson 3.4.3

  13. ABD — Guessing required.
    • C: DCFL.

    Review lesson 3.4.4

  14. D — Two comparisons at once.
    • A: No.
    • B: No.
    • C: No.

    Review lesson 3.4.4

  15. A — Finite.
    • B: Finite languages are regular.
    • C: No.
    • D: No.

    Review lesson 3.4.4

Ready for the next idea?

Mark this item complete when you’ve finished reading and working through it.