CS Atlas GATE 2027
TOC course
0 / 91 complete

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

Chapter review L3.3 · Item 58 of 91

Push-down automata

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

On this page

Chapter recap

A PDA is a finite automaton with an unbounded stack: moves read a symbol or ε, look at the top, and replace it by a string. Acceptance by final state and by empty stack are equivalent for NPDAs; empty-stack DPDAs accept only prefix-free languages, so DCFLs use final state. DPDAs forbid competing moves; Regular ⊊ DCFL ⊊ CFL (wwᴿ separates). CFGs ↔ PDAs: expand/match simulation of leftmost derivations, and [pXq] triples back.

Merged rule card

From 3.3.1 Stack primer and the push-down automaton

  • PDA (Q, Σ, Γ, δ, q₀, Z₀, F); δ(q, a|ε, X) ⊆ Q × Γ*; label a, X/γ (γ = ε pop, X keep, YX push).
  • ID (q, w, γ), top first; ⊢ one move, ⊢* many.
  • Nondeterministic by default; ε-moves still see the stack.

From 3.3.2 Acceptance by final state vs empty stack

  • Final state: input read, state ∈ F, stack anything. Empty stack: input read, stack empty, state anything.
  • NPDA: both conventions = CFL (convert with a new bottom marker).
  • DPDA: empty stack ⇒ only prefix-free DCFLs; final state ⇒ all DCFLs. GATE default: final state.

From 3.3.3 Designing PDAs; DPDA vs NPDA; DCFL ⊂ CFL

  • Recipe: stack stores what is unbounded; states store the phase; Z₀ detects empty; accept via ε, Z₀.
  • DPDA: ≤ 1 move per (q, a|ε, X), and no ε-move competing with input moves.
  • Regular ⊊ DCFL ⊊ CFL. wwᴿ, aⁿbⁿ ∪ aⁿb²ⁿ, aⁱbʲcᵏ (i=j or j=k): CFL not DCFL.
  • DCFL ⇒ unambiguous grammar; not conversely.

From 3.3.4 CFG ↔ PDA equivalence

  • CFG → PDA: push S; expand (q, ε, A) → (q, α); match (q, a, a) → (q, ε); accept on Z₀. Simulates leftmost derivations; nondeterministic.
  • PDA → CFG: variables [p X q] (net pop of X from p to q).
  • CFG = NPDA (final state) = NPDA (empty stack). One working state suffices.

Practice questions

  1. MCQ

    Which language needs nondeterminism in a PDA?

    1. { aⁿbⁿ }
    2. { wcwᴿ }
    3. { wwᴿ }
    4. { aⁿbᵐ : n ≥ m }
  2. MSQ

    Which are true?

    1. Every regular language is a DCFL
    2. Every DCFL is unambiguous
    3. DPDA = NPDA in power
    4. Final-state and empty-stack NPDAs are equivalent
  3. NAT

    ID (q, ab, AZ). Move δ(q, a, A) ∋ (p, BBA). Stack size after the move?

    Write your answer before opening the key.

  4. MCQ

    A PDA accepting by empty stack ends with input read in a non-accepting state with Z on the stack. It:

    1. accepts
    2. rejects
    3. loops
    4. depends on F
  5. MSQ

    Which are CFL but not DCFL?

    1. { wwᴿ }
    2. { aⁿbⁿ } ∪ { aⁿb²ⁿ }
    3. { aⁱbʲcᵏ : i = j or j = k }
    4. { aⁿbⁿ }
  6. MCQ

    In CFG → PDA, the move for terminal a is:

    1. (q, ε, a) → (q, ε)
    2. (q, a, a) → (q, ε)
    3. (q, a, Z) → (q, aZ)
    4. (q, a, A) → (q, a)
  7. NAT

    Empty-stack DPDAs can accept a language L only if L is prefix-free. How many strings of { a, ab, b, ba } must be removed to make it prefix-free (remove as few as possible)?

    Write your answer before opening the key.

  8. MCQ

    Which is a DCFL?

    1. { wwᴿ }
    2. { aⁿbᵐcⁿ }
    3. { aⁱbʲcᵏ : i = j or j = k }
    4. { aⁿbⁿcⁿ }

Answer key

Reveal answers when you’re ready
  1. C — No middle marker.
    • A: DPDA.
    • B: DPDA.
    • D: DPDA.
  2. ABD — Standard facts.
    • C: NPDA is stronger.
  3. 4 — Replace A by BBA: BBAZ.
  4. B — Stack is not empty.
    • A: Z still there.
    • C: Not determined by this.
    • D: F is irrelevant.
  5. ABC — Standard examples.
    • D: DCFL.
  6. B — Match and pop.
    • A: Must read a.
    • C: That pushes.
    • D: Wrong.
  7. 2 — a is a prefix of ab, b of ba: remove one from each pair.
  8. B — Push a’s, ignore b’s, pop on c’s.
    • A: Needs guessing.
    • C: Inherently ambiguous.
    • D: Not even a CFL.

Ready for the next idea?

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