CS Atlas GATE 2027
TOC course
0 / 91 complete

TOC/Phase 4 · Turing Machines

Phase bridge B4 · Item 65 of 91

Context-free languages, recalled

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

On this page

Where you are in the story

Phase 3 gave machines one stack. Phase 4 gives them a tape they can read, write and move along freely. Before the jump, make sure the stack world is solid — the containment chain you will build next starts with Regular ⊂ DCFL ⊂ CFL.

Previous phase in pictures

Grammar ↔ stack machine

CFG
A → α
PDA
expand / match, one stack
CFL
same family
Two descriptions of context-free languages.

The hierarchy so far

CFL NPDA — wwᴿ
DCFL DPDA — aⁿbⁿ, wcwᴿ
Regular DFA
Both inclusions are strict.

A stack run

PDA for aⁿbⁿ (final state)

States: q0, q1, q2

Transitions: q0>q0: a,Z/AZ | a,A/AA; q0>q1: b,A/ε; q1>q1: b,A/ε; q1>q2: ε,Z/Z; q0>q2: ε,Z/Z

Push on a, pop on b, accept on Z.

Closure, side by side

operationRegDCFLCFL
∪✓✗✓
∩✓✗✗
complement✓✓✗
concat / star✓✗✓
∩ regular✓✓✓

Where one stack fails

Two comparisons at once: no PDA. A Turing machine will handle it easily (4.1.2).
Two comparisons at once: no PDA. A Turing machine will handle it easily (4.1.2).

Carry these forward

What makes a grammar context-free?

One variable on the left of every rule. (3.1.1)

When is a grammar ambiguous?

Some string has two parse trees. (3.1.3)

CNF derivation steps for length n?

2n − 1. (3.2.2)

PDA 7-tuple?

(Q, Σ, Γ, δ, q₀, Z₀, F). (3.3.1)

Empty-stack DPDAs accept which languages?

Only prefix-free DCFLs. (3.3.2)

Standard CFL that is not a DCFL?

wwᴿ. (3.3.3)

Are CFLs closed under complement?

No; DCFLs are. (3.4.1)

CYK time?

O(n³ · |G|). (3.4.2)

CFL pumping window?

|vwx| ≤ p, |vx| ≥ 1. (3.4.3)

Is ww context-free?

No (its complement is). (3.4.4)

Quick refresher

  1. MCQ

    Which is CFL but not DCFL?

    1. aⁿbⁿ
    2. wwᴿ
    3. wcwᴿ
    4. a*b*
  2. MSQ

    Which are not CFLs?

    1. aⁿbⁿcⁿ
    2. ww
    3. aⁿbᵐcⁿ
    4. a^{prime}
  3. NAT

    CNF steps for a string of length 6?

    Write your answer before opening the key.

  4. MCQ

    CFLs are closed under:

    1. intersection
    2. complement
    3. Kleene star
    4. difference

What the next phase adds

finite control
+ stack
top only
+ tape
read, write, move both ways
every computable function
Church–Turing
Phase 4: the last upgrade in memory.

Answer Vault

Reveal answers when you’re ready
  1. B — Middle must be guessed.
    • A: DCFL.
    • C: DCFL.
    • D: Regular.
  2. ABD — Standard non-CFLs.
    • C: DCFL.
  3. 11 — 2n − 1.
  4. C — Grammar S → S₁S | ε.
    • A: No.
    • B: No.
    • D: No.

Ready for the next idea?

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