GATE / CS ARCHIVE

SUBJECT COLLECTION

Theory of Computation · Pushdown Automata

21 questions, newest first

GATE CSE has asked 21 questions on Pushdown Automata (Theory of Computation) from 1994 to 2025, in 18 of the 46 papers; the most recent is in GATE CSE 2025 Set 2. In the last five years it carried 0.4 marks per 100-mark paper on average, against 0.5 since 2003. Since 2014 the questions have been 6 MCQ and 1 NAT. 3 groups of questions here are solved the same way; “One per method” keeps the newest of each.

Browse topics
1 mark · MCQ
Report issue

Pushdown Automata

Question 24, GATE 2025: Which family is guaranteed to be accepted by deterministic pushdown automata, meaning that every language in the listed family has some DPDA?
Options: A. every regular language; B. every context-free language; C. every language accepted by an NPDA; D. every decidable language.
Tap to enlarge
Your answer
Answer & solution

Official answer: A

A DPDA can simulate a DFA: copy the DFA's finite control and transitions, and leave the stack unused except for its bottom marker. Therefore every regular language has a deterministic pushdown recognizer, establishing A.

Nondeterministic PDAs recognize exactly the context-free languages, while deterministic PDAs recognize only the deterministic context-free languages, a proper subclass. Thus B and C make the same overly broad guarantee. For example, the unrestricted palindrome language over {a,b} requires guessing the midpoint in the usual PDA construction and is not deterministic context-free; a visible midpoint marker would change the problem.

D is even broader. A decidable language such as {an bn cn:n≥0} can be decided by a Turing machine but is not context-free, so no PDA, deterministic or nondeterministic, accepts it. These statements concern existence of a suitable machine for each language, not one fixed machine that accepts every language at once. Answer: A.

Original paper, page 20 · Answer key

2 marks · MCQ
Report issue

Pushdown Automata

Question 40, GATE 2023: An empty-stack-accepting PDA starts in s with stack ⊥. In s, a/⊥/A⊥ and a/A/AA push one A. Transition s→p and the loop at p are b/A/ε. Transitions s→q and p→q are ε/A/ε. At q, ε/A/ε and ε/⊥/ε empty the stack. Describe its accepted language over {a,b}, consuming all input.
Tap to enlarge
Your answer
Answer & solution

Official answer: A

In s each a pushes A. The first b moves to p and pops A, and further b’s pop more A. Entry to the cleanup state q requires an A at the stack top and pops it, so at least one A must remain after all input has been read. Then q removes the remaining stack symbols, including the bottom marker. Consequently input is aᵐbⁿ with m≥1 and 0≤n<m, option A. Equal counts leave only the bottom symbol in s/p and cannot enter q; epsilon is not accepted.

Teaching detail. After reading m a's, the stack is Am⊥. Reading n b's pops n A's, leaving Am−n⊥. The only gateway to the cleanup state consumes one further A without consuming input, which is possible precisely when m−n≥1. Cleanup cannot read more input, so all a's and b's must already have been consumed. Pure a strings with m≥1 are accepted via s→q; the empty string is not, because no transition from s pops ⊥ directly. The strict inequality n<m, not n≤m, is therefore essential.

Original paper, page 41 · Answer key

2 marks · NAT
Report issue

Pushdown Automata

Question 51, GATE 2021: A PDA has states q0,q1,q2,q3, start q0 and only final state q3, input {a,b} and stack alphabet {#,A}. Transition label input,pop→push is used, with ε meaning no input/pop/push. Transitions: q0→q1: ε,ε→#; q1 loop: a,ε→A; q1→q2: ε,ε→ε; q2 loop: b,A→ε; q2→q3: ε,A→A. There are no other transitions. How many length-100 strings are accepted by final state?
Tap to enlarge
Answer & solution

Official answer: 50

The PDA first pushes its bottom marker, then pushes one A for each initial a. In the second phase it pops one A for each b. Reaching the final state requires an A still on top, so the language is am bn with m>n>=0. For total length 100, n can be any integer from 0 through 49, with m=100-n. Each choice determines one string, giving 50. The accepting-state transition preserves that remaining A; acceptance is by final state rather than empty stack.

While reading a's, the stack contains one A per a above #. After switching to q2, each b removes one A and no a-transition exists, enforcing the order a* b*. The final ε-transition tests and preserves an A, requiring strictly more a's than b's. For length 100, m+n=100 and m>n give 100−n>n, so n<50. Each n=0,...,49 gives one word a100−nbn, including a100; equality at n=50 is not accepted.

Original paper, page 40 · Answer key

1 mark · MCQ
Report issue

Pushdown Automata

Question 10, GATE 2020: L={a^n:n≥0}∪{a^n b^n:n≥0}. Test I L is deterministic context-free; II L is context-free but not deterministic context-free; III L is not LL(k) for any k. Options: A I only; B II only; C I and III; D III only.
Question 10, GATE 2020: L={a^n:n≥0}∪{a^n b^n:n≥0}. Test I L is deterministic context-free; II L is context-free but not deterministic context-free; III L is not LL(k) for any k. Options: A I only; B II only; C I and III; D III only.
Tap to enlarge
Your answer
Answer & solution

Official answer: C

Worked explanation

A deterministic pushdown recognizer can use an accepting a-phase, initially with a bottom marker. Each a pushes one marker. Seeing the first b changes permanently to a b-phase and pops one marker per b; a b with no marker, or any later a, rejects. At end-of-input it accepts either the a-phase (including ε) or the b-phase with exactly the bottom marker left. This establishes I constructively and rejects II. The familiar non-LL(k) separation is a language-level result: do not infer it merely because the obvious grammar S→A|B, A→aA|ε, B→aBb|ε has a FIRST-set conflict. The shared-prefix argument below explains the obstruction; a full formal proof that no equivalent LL(k) grammar exists requires the bounded-lookahead language theorem, not just testing that one grammar. III is the standard classification used by the official answer.

Derivation and answer

A DPDA pushes while reading a symbols, then pops one per b after the first b. It accepts an all-a input by final state at end-of-input, and accepts an an bn input when the count matches, so the language is deterministic context-free. The standard strict-separation example a* union {an bn} is not an LL(k) language for any finite k: arbitrarily long common a-prefixes postpone the distinction between an unmatched all-a ending and the matching b-suffix beyond any fixed lookahead. A predictive leftmost derivation cannot use that late distinction to discharge an unbounded number of already predicted matching b obligations. This is the language-level bounded-lookahead obstruction, not merely an observation that one displayed grammar is not left-factored. Thus I and III, C.

Original paper, page 6 · Answer key

2 marks · MCQ
Report issue

Pushdown Automata

Question 43, GATE 2016: A PDA over input {a,b}, stack {X,Z}, starts with stack Z. Its start state q0 and state q2 are accepting; q1 is not. q0 loops on a,X/XX and a,Z/XZ; q0→q1 is b,X/ε; q1 loops on b,X/ε; q1→q2 is ε,Z/Z. There are no other transitions. Acceptance is by final state after consuming the whole input. Which statement is true? A:L={a^n b^n:n≥0}, not finite-automaton recognizable. B:L=a* union {a^n b^n:n≥0}, not accepted by any deterministic PDA. C:L is not accepted by any Turing machine halting on all inputs. D:L=a* union {a^n b^n:n≥0}, and is deterministic context-free.
Tap to enlarge
Your answer
Answer & solution

Official answer: D

The initial state is accepting, so epsilon and every a-only word are accepted while pushing one X per a. On the first b the machine moves to the middle state and pops one X per b; it reaches the final accepting state only when the stack returns to Z. Therefore the additional accepted words are an bn. The displayed machine is deterministic: at each state/stack combination the input transitions do not compete with epsilon transitions. The language is a* union {an bn: n≥0}, a deterministic CFL, D.

Final-state acceptance does not require an empty stack. This is why an all-a input is accepted in q0 even with X symbols left above Z, and why the double circle on the start state matters. Once a b occurs the machine cannot return to q0 or read further a symbols. It can reach q2 exactly after the number of b symbols matches the pushed X count. At q1, b-transitions require top X whereas the ε-transition requires top Z, so they are never simultaneously enabled; determinism is preserved.

Original paper, page 17 · Answer key

2 marks · MCQ
Report issue

Pushdown Automata

Question 50, GATE 2015: NPDA states q0(start),q1,q2(final), stack bottom ⊥. At q0 read b∈{0,1} and push b; transition to q1 may consume 0,1,or ε without changing stack. At q1 read 0 and pop 1, or read 1 and pop 0. With only ⊥ left, ε-pop it and enter q2. Which suffix appended to 101100 is accepted? A 10110; B 10010; C 01010; D 01001.
Tap to enlarge
Your answer
Answer & solution

Official answer: B

The push phase remembers a prefix in reverse order; the pop phase checks its complemented reverse. Thus accepted strings have form w z complement(reverse(w)), where z is empty or one symbol. Every listed concatenation has eleven symbols, forcing |w|=5 and one middle symbol. Here w=10110, middle=0, and reverse(w)=01101. Complementing gives 10010. The nondeterministic phase switch is constrained by total length, so one cannot push all six supplied prefix bits.

Solution: The NPDA pushes a prefix, optionally consumes a middle symbol while changing phase, then pops only on the complementary symbol. The full listed strings have length 11, so the first five symbols 10110 are pushed and the sixth 0 is the middle. The remaining five must be the complement of the reversed prefix: reverse 10110=01101, complement 10010. Thus B.

Original paper, page 18 · Answer key

2 marks · MCQ
Report issue

Pushdown Automata

Question 36, GATE 2014: Over Σ={0,1,c}, define L1={0ⁿ1ⁿ:n≥0}, L2={wcwʳ:w∈{0,1}*}, L3={wwʳ:w∈{0,1}*}, with wʳ the reversal of w. Which languages are deterministic context-free? A none; B only L1; C only L1,L2; D all three.
Tap to enlarge
Your answer
Answer & solution

Official answer: C

Step 1: For L1, a deterministic pushdown automaton pushes one marker per 0 and switches to popping when the first 1 appears. The input symbol change identifies the phase boundary; accept when the counts match. Step 2: For L2, push the first binary word, then the marker c deterministically signals the switch to matching and popping its reverse. Step 3: In L3 there is no midpoint marker. An arbitrary binary even palindrome requires a nondeterministic choice of when to switch, and this unmarked palindrome language is a standard CFL that is not deterministic context-free. Therefore C. The final claim is the known non-DCFL result, not a claim that every language with an unmarked midpoint is automatically nondeterministic.

Original paper, page 61 · Answer key

1 mark · MCQ
Report issue

False claim about pushdown determinism

Pushdown Automata

Question 16, GATE 2009: Which is false? A each regular language has a unique minimal DFA (up to renaming); B each NFA has an equivalent PDA; C the complement of every CFL is recursive; D every NPDA has an equivalent DPDA.
Tap to enlarge
Your answer
Answer & solution

Answer: D (no official key was published)

Minimal DFAs are unique up to state renaming; an NFA can be simulated by a PDA that ignores its stack. Every CFL is decidable, so its complement is recursive. But deterministic PDAs recognize a proper subclass of the CFLs recognized by NPDAs. Thus the universal conversion in D is false.

A PDA can simulate an NFA without using its stack. Context-free membership is decidable, so complementing that decision gives a decider for the complement. Minimal DFAs are unique up to state renaming. Deterministic PDAs, however, recognize a proper subset of context-free languages; nondeterminism cannot always be eliminated. For instance, unmarked palindromes need a nondeterministic guess of the midpoint. Thus D is the false universal claim.

Original paper, page 3

2 marks · MCQ
Report issue

Equal blocks separated by a marker

Pushdown Automata

Question 30, GATE 2007: Classify L={0^i 2 1^i:i≥0} over alphabet {0,1,2}.
Options:
(A) Not recursive
(B) Recursive and deterministic context-free
(C) Regular
(D) Context-free but not deterministic context-free
Tap to enlarge
Your answer
Answer & solution

Answer: B (no official key was published)

1. Approach. The marker 2 identifies exactly when to switch from pushing zeros to matching ones. Unlike an unmarked palindrome, there is no need to guess the midpoint.

2. Derivation and interpretation. A deterministic PDA pushes for each initial 0, switches phase at the unique marker 2, and pops once per 1, accepting exactly when the counts match and input ends. Membership is also decidable. The language is not regular because matching unbounded block lengths requires memory. Hence it is recursive and deterministic context-free, B, including the string 2 for i=0.

Original paper, page 7

2 marks · MCQ
Report issue

Determinism in finite and pushdown automata

Pushdown Automata

Question 54, GATE 2005: Let Df, Nf, Dp, Np denote languages accepted by deterministic finite, nondeterministic finite, deterministic pushdown and nondeterministic pushdown automata. Determine the equality/proper-inclusion relationships. The intended option D is Df=Nf and Dp properly contained in Np. Other options: A both inclusions proper; B Df proper subset Nf and Dp=Np; C both pairs equal.
Tap to enlarge
Your answer
Answer & solution

Answer: D (no official key was published)

Subset construction converts any NFA into a DFA, so Df=Nf. A DPDA is a restricted NPDA, and the inclusion Dp⊊Np is strict, for example unmarked even palindromes require nondeterministic midpoint choice. Thus D. The printed subset symbol is interpreted as proper inclusion.

For finite automata, a DFA state can represent the full subset of possible NFA states after each prefix, so nondeterminism does not increase language expressive power. For pushdown automata, deterministic computation cannot generally guess an unmarked midpoint while preserving the necessary stack comparison. Every deterministic machine is a special nondeterministic one, but some CFLs such as unmarked even palindromes are not deterministic CFLs. Hence the first pair is equal and the second inclusion is strict.

Original paper, page 7

2 marks · MCQ
Report issue

Marked palindromes versus copying

Pushdown Automata

Question 57, GATE 2005: For binary w, L1={wwᴿ}, L2={w#wᴿ} with special delimiter#, L3={ww}. Which is true? A L1 deterministic CFL; B L2 deterministic CFL; C L3 CFL but not deterministic; D L3 deterministic CFL.
Tap to enlarge
Your answer
Answer & solution

Answer: B (no official key was published)

For L2={w#wR}, a DPDA pushes before # and then deterministically pops and compares after #; it accepts exactly upon a complete match. L1={wwR} has no delimiter and is context-free but not deterministic context-free. L3={ww} is not context-free. Therefore B.

For the delimited language, # tells the PDA exactly when to switch from pushing to comparing/popping. Every decision is determined by current input and stack top, so the recognizer is deterministic. Without the delimiter, a palindrome PDA must in general choose the midpoint nondeterministically. The duplicated-word language requires preserving the same order twice, not the reverse stack order, and is not CFL. These distinctions are about whole language classes, not whether some individual examples can be recognized.

Original paper, page 7

1 mark · MCQ
Report issue

Pushdown automaton with bounded stack

Pushdown Automata

Question 1.7, GATE 2002: A pushdown automaton is restricted to at most 10 stack items. Which class best describes the language it accepts?
(A) Context-free; (B) Regular; (C) Deterministic context-free; (D) Recursive.
Tap to enlarge
Your answer
Answer & solution

Answer: B (no official key was published)

Step 1: Turn stack contents into finite control.

Step 2: If the stack alphabet has s symbols, at most 1+s+…+s10 stack words are possible. With q control states, at most q(1+s+…+s10) combined configurations are needed, apart from fixed acceptance bookkeeping. Every push/pop transition can be represented between these finite states, so an unbounded-memory PDA advantage is absent.

Conclusion: A fixed finite stack alphabet and maximum stack height 10 allow only finitely many stack strings. Pairing each with the finite control state yields a finite automaton, including epsilon transitions if needed. Hence the language is regular, B; the larger language classes listed are less precise.

Original paper, page 1

Descriptive
Report issue

Deterministic PDA for aⁿcb²ⁿ

Pushdown Automata

Question 6, GATE 2001: L={aⁿcb²ⁿ | n≥1}, alphabet {a,b,c}; specify accepting state.

Task: Construct a deterministic PDA and specify its accepting state.
Tap to enlarge
Shared context

L={aⁿcb²ⁿ | n≥1}, alphabet {a,b,c}; specify accepting state.

Answer & solution

Answer: Push two X markers per a, consume one per b after c, accept only on exhaustion of markers and input. (no official key was published)

1. Use stack alphabet {Z,X} with bottom marker Z, and states q0 (start), qA (a phase), qB (b phase), qF (sole accepting state). Stack top is written at the left. A transition (q,s,T)→(p,γ) consumes s and replaces top T by γ.

2. Define δ(q0,a,Z)=(qA,XXZ); δ(qA,a,X)=(qA,XXX); δ(qA,c,X)=(qB,X); δ(qB,b,X)=(qB,ε); δ(qB,ε,Z)=(qF,Z). All unspecified transitions reject. Accept by final state only after all input is consumed.

3. The first a is required to leave q0, enforcing n≥1. Each subsequent a replaces one X with three, a net push of two; after n a symbols there are exactly 2n markers. The unique c switches irreversibly to qB.

4. Each b pops one X. Exactly 2n b symbols expose Z, allowing the ε-move to qF. Too few leave the PDA nonaccepting; extra input cannot be consumed from qF. Wrong symbol order has no transition.

5. Determinism holds because qB has a b transition only with top X and an ε-transition only with top Z; no fixed state/top pair offers both an ε-transition and an input transition.

Original paper, page 7

Descriptive
Report issue

Completing a reverse-matching PDA

Pushdown Automata

Question 8(a), GATE 2000: Two states q₀ (initial) and q₁. Existing edges: q₀→q₀ labeled 1,s/1s; q₀→q₁ labeled 2,s/s; q₁→q₁ labeled 1,1s/s. A label d,u/v consumes d and replaces entire stack u by v; s denotes the arbitrary remainder, top at left. Target L={x2xᴿ:x∈{0,1}*}.

Task: Add two appropriately labeled edges to accept L by empty stack.
Question 8(a), GATE 2000: Two states q₀ (initial) and q₁. Existing edges: q₀→q₀ labeled 1,s/1s; q₀→q₁ labeled 2,s/s; q₁→q₁ labeled 1,1s/s. A label d,u/v consumes d and replaces entire stack u by v; s denotes the arbitrary remainder, top at left. Target L={x2xᴿ:x∈{0,1}*}.

Task: Add two appropriately labeled edges to accept L by empty stack.
Question 8(a), GATE 2000: Two states q₀ (initial) and q₁. Existing edges: q₀→q₀ labeled 1,s/1s; q₀→q₁ labeled 2,s/s; q₁→q₁ labeled 1,1s/s. A label d,u/v consumes d and replaces entire stack u by v; s denotes the arbitrary remainder, top at left. Target L={x2xᴿ:x∈{0,1}*}.

Task: Add two appropriately labeled edges to accept L by empty stack.
Tap to enlarge
Shared context

Two states q₀ (initial) and q₁. Existing edges: q₀→q₀ labeled 1,s/1s; q₀→q₁ labeled 2,s/s; q₁→q₁ labeled 1,1s/s. A label d,u/v consumes d and replaces entire stack u by v; s denotes the arbitrary remainder, top at left. Target L={x2xᴿ:x∈{0,1}*}.

Answer & solution

Answer: Add q₀→q₀: 0,s/0s and q₁→q₁: 0,0s/s. Exact formal acceptance requires the caveat below. (no official key was published)

1. The missing push edge is a q₀ self-loop labeled 0,s/0s. The missing matching-pop edge is a q₁ self-loop labeled 0,0s/s. Together with the existing 1 loops these handle both symbols.

2. Before the delimiter, q₀ pushes every input symbol. The sole 2 edge enters q₁ without changing the stack. After it, each input bit must match the top bit and pops it; mismatches have no move.

3. For x=01, the successive configurations are (q₀,01210,ε)→(q₀,1210,0)→(q₀,210,10)→(q₁,10,10)→(q₁,0,0)→(q₁,ε,ε). Thus the intended accepting condition is exhausted input, empty stack, and completed delimiter transition into q₁.

4. Formal defect: under ordinary acceptance by empty stack in ANY state, an initially empty stack accepts ε immediately, although ε∉L. The two requested edges cannot undo this existing accepting run. An initial bottom marker does not alone solve it: none of the displayed or added transitions removes that marker.

5. To formalize the intended construction, require q₁ together with empty stack at input end; alternatively start with bottom marker Z and additionally permit q₁→q₁ labeled ε,Z/ε. The latter is a third added edge and therefore exceeds the literal two-edge request. We report the intended pair without claiming it repairs the original formal specification.

Original paper, page 7

Descriptive
Report issue

Three-state PDA for bounded ratios

Pushdown Automata

Question 8(b), GATE 2000: Target L={0ⁿ1ᵐ:n≤m≤2n}, with n,m nonnegative. Use labels d,u/v to consume d and replace entire stack u by v; stack top is at left.

Task: Describe a nondeterministic three-state PDA accepting by empty stack.
Question 8(b), GATE 2000: Target L={0ⁿ1ᵐ:n≤m≤2n}, with n,m nonnegative. Use labels d,u/v to consume d and replace entire stack u by v; stack top is at left.

Task: Describe a nondeterministic three-state PDA accepting by empty stack.
Question 8(b), GATE 2000: Target L={0ⁿ1ᵐ:n≤m≤2n}, with n,m nonnegative. Use labels d,u/v to consume d and replace entire stack u by v; stack top is at left.

Task: Describe a nondeterministic three-state PDA accepting by empty stack.
Tap to enlarge
Shared context

Target L={0ⁿ1ᵐ:n≤m≤2n}, with n,m nonnegative. Use labels d,u/v to consume d and replace entire stack u by v; stack top is at left.

Answer & solution

Answer: Push one X per 0; nondeterministically consume either one or two 1s per X using three states. (no official key was published)

1. Use states p (initial zero-reading phase), q (one-reading phase), r (one more 1 required for the current X). Start with empty stack. Edges: p→p: 0,s/Xs; p→q: ε,s/s; q→q: 1,Xs/s; q→r: 1,Xs/Xs; r→q: 1,Xs/s. There are no other edges. Accept only when all input is consumed and the stack is empty, in any state.

2. The zero phase pushes n copies of X. After the ε transition to q, no transition reads a zero, so every accepted word has form 0ⁿ1ᵐ.

3. For each X, q may consume one 1 and pop immediately, or consume one 1 without popping, enter r, and require a second 1 to pop and return to q. State r cannot have an empty stack because its entry edge requires and retains an X.

4. If k of the n markers use the two-symbol option, total ones are m=n+k with 0≤k≤n. Conversely any m in [n,2n] is realized by selecting k=m−n markers for that option.

5. The empty word is correctly accepted for n=m=0. A nonempty all-zero word leaves markers, a leading 1 has no applicable pop, and extra 1s cannot be read after the last marker disappears. This verifies the boundary cases without a bottom-marker convention.

Original paper, page 7

1 mark · MCQ
Report issue

Two PDA acceptance conventions

Pushdown Automata

Question 1.6, GATE 1999: Compare languages accepted by final state and by empty stack: equal classes, one proper inclusion, or incomparable?
Tap to enlarge
Your answer
Answer & solution

Answer: A for nondeterministic PDAs (no official key was published)

An empty-stack PDA can be turned into a final-state PDA by adding a protected bottom marker and moving to an accepting state when the original stack empties. Conversely, a final-state PDA can nondeterministically enter a stack-draining phase after reaching an accepting state; acceptance still requires consuming the whole input. These constructions preserve the recognized language and show equal classes, A. The statement is for unrestricted nondeterministic PDAs. Deterministic acceptance conventions have additional restrictions and cannot be substituted without qualification.

Original paper, page 1

Descriptive
Report issue

Language of a PDA

Pushdown Automata

Question 13(a), GATE 1998: For the displayed PDA on states q0,q1, alphabet {0,1}, stack {Z0,X}, start (q0,Z0), and empty-store acceptance, determine its language. Common transitions: (q0,1,Z0)→(q0,XZ0), (q0,ε,Z0)→(q0,ε), (q0,1,X)→(q0,XX), (q1,1,X)→(q1,ε). GFG has (q0,0,Z0)→(q1,X) and (q1,0,Z0)→(q0,Z0); GateForum instead has (q0,0,X)→(q1,X) and (q0,0,Z0)→(q0,Z0).
Question 13(a), GATE 1998: For the displayed PDA on states q0,q1, alphabet {0,1}, stack {Z0,X}, start (q0,Z0), and empty-store acceptance, determine its language. Common transitions: (q0,1,Z0)→(q0,XZ0), (q0,ε,Z0)→(q0,ε), (q0,1,X)→(q0,XX), (q1,1,X)→(q1,ε). GFG has (q0,0,Z0)→(q1,X) and (q1,0,Z0)→(q0,Z0); GateForum instead has (q0,0,X)→(q1,X) and (q0,0,Z0)→(q0,Z0).
Tap to enlarge
Answer & solution

Answer: As printed: {ε, 01}. A plausible repaired PDA accepts (⋃_(n≥1)1^n01^n0)*. (no official key was published)

Empty-store acceptance requires both the entire input to be consumed and the stack to be empty. Merely reaching Z0, or emptying the stack while unread input remains, is not sufficient. The two printed transition sets differ materially, so there is no source-independent single language.

The paper literal version: at (q0,Z0), ε can pop Z0 and accept ε. Reading 0 uses its printed transition (q0,0,Z0)→(q1,X), replacing Z0 rather than preserving it. One subsequent 1 pops X and accepts 01 with an empty stack. No further input can then be consumed. Reading any 1 first puts X above Z0 in q0; that state can only push more X on further 1s, because the paper's zero transition tests Z0, not X. It can never enter its popping phase from such a stack. Thus L={ε,01}. The printed q1,0,Z0 return transition is unreachable from the start in this literal machine.

It cannot empty Z0. Hence no string containing a 1 is accepted and L_GF=0*.

It pushes n≥1 Xs on 1s, reads 0 to switch phase, pops n Xs on 1s, then reads another 0 to return to q0. It can repeat such blocks and finally pop Z0 by ε. Conditional on exactly those repairs, the language is (⋃_(n≥1){1^n01^n0})*. The choice n≥1 is necessary because no q0,0,Z0 transition remains in this repair. This reconstructed answer is useful but not verified as the original question; silently substituting it would conceal different literal answers.

Original paper, page 7

Descriptive
Report issue

Explain the PDA stack behavior

Pushdown Automata

Question 13(b), GATE 1998: For the displayed PDA on states q0,q1, alphabet {0,1}, stack {Z0,X}, start (q0,Z0), and empty-store acceptance, describe its operation informally. Common transitions: (q0,1,Z0)→(q0,XZ0), (q0,ε,Z0)→(q0,ε), (q0,1,X)→(q0,XX), (q1,1,X)→(q1,ε). GFG has (q0,0,Z0)→(q1,X) and (q1,0,Z0)→(q0,Z0); GateForum instead has (q0,0,X)→(q1,X) and (q0,0,Z0)→(q0,Z0).
Question 13(b), GATE 1998: For the displayed PDA on states q0,q1, alphabet {0,1}, stack {Z0,X}, start (q0,Z0), and empty-store acceptance, describe its operation informally. Common transitions: (q0,1,Z0)→(q0,XZ0), (q0,ε,Z0)→(q0,ε), (q0,1,X)→(q0,XX), (q1,1,X)→(q1,ε). GFG has (q0,0,Z0)→(q1,X) and (q1,0,Z0)→(q0,Z0); GateForum instead has (q0,0,X)→(q1,X) and (q0,0,Z0)→(q0,Z0).
Tap to enlarge
Answer & solution

Answer: See the solution below (no official key was published)

A transition (q,a,T)→(p,γ) consumes a when a≠ε, changes state to p, and replaces the top stack symbol T by γ. Take the leftmost stack symbol as the top. Thus replacing X by XX pushes one extra counter symbol, while replacing X by ε pops one.

In the plausible reconstruction specified in part (a), q0 is a counting-up phase and q1 a counting-down phase. Start with Z0. Each leading 1 pushes one X. A 0 with X on top switches q0→q1 without changing the stack. Each following 1 in q1 pops one X. Once only Z0 remains, another 0 returns to q0 without removing Z0. The machine may process another block in the same way. Only at q0 with top Z0 may ε remove the bottom marker, accepting if input is exhausted.

For reconstructed input 110110, the configurations (state, unread input, stack) are
(q0,110110,Z0)
→(q0,10110,XZ0)
→(q0,0110,XXZ0)
→(q1,110,XXZ0)
→(q1,10,XZ0)
→(q1,0,Z0)
→(q0,ε,Z0)
→(q0,ε,ε).

An extra 1 in the popping phase has no transition once Z0 is reached; too few 1s leave X on top when the closing 0 is encountered, also blocking the run. These restrictions enforce equal positive counts within every block. The four-phase explanation applies only to the explicitly repaired transition set, not literally to both printed versions.

Literal machine the special input 01 instead replaces Z0 by X on its first step, then pops X, so that machine accepts only ε and 01. These observations explain why the attractive counting-machine interpretation cannot be presented without disclosing the source repairs. All unspecified transitions are treated as absent, not guessed.

Original paper, page 7

2 marks · MCQ
Report issue

Deterministic recognition with a middle marker

Pushdown Automata

Question 6.6, GATE 1997: Which language is deterministic context-free: {wcwR:w∈{a, b}*}, unmarked even palindromes over{a, b, c}, {a^n b^n c^n}, or all palindromes over{a, b, c}?
Question 6.6, GATE 1997: Which language is deterministic context-free: {wcwR:w∈{a, b}*}, unmarked even palindromes over{a, b, c}, {a^n b^n c^n}, or all palindromes over{a, b, c}?
Tap to enlarge
Your answer
Answer & solution

Answer: A (no official key was published)

For A, the symbol c uniquely marks the midpoint because w uses only a, b. A DPDA pushes symbols before c, then deterministically switches to popping and comparing symbols after c, accepting when they match exactly and input ends. Unmarked palindrome languages require finding an unspecified midpoint and are not deterministic context-free over a multi-symbol alphabet. The equal-three-block language is not even context-free. Hence A. The delimiter’s exclusion from w is essential; without it, the same deterministic switch is unavailable.

Original paper, page 5

5 marks · Descriptive
Report issue

Complete a palindrome PDA carefully

Pushdown Automata

Question 13, GATE 1996: A PDA with states q1,q2, alphabet {a,b}, stack alphabet {a,b,Z}, initial state q1 and stack Z accepts nonempty even palindromes by empty stack. Stack top is at the right. Given δ(q1,a,Z)={(q1,Za)}, δ(q1,b,Z)={(q1,Zb)}, δ(q2,a,a)={(q2,ε)}, δ(q2,b,b)={(q2,ε)}, δ(q2,ε,Z)={(q2,ε)}, fill the two alternatives in each of δ(q1,a,a) and δ(q1,b,b). Discuss whether the displayed list is sufficient.
Tap to enlarge
Answer & solution

Answer: δ(q1,a,a)={(q1,aa),(q2,ε)}; δ(q1,b,b)={(q1,bb),(q2,ε)}. Also require δ(q1,a,b)={(q1,ba)} and δ(q1,b,a)={(q1,ab)}. (no official key was published)

In state q1, the machine is guessing and storing the first half. On a matching input/top pair, it has two nondeterministic choices: push that input as another first-half symbol, or treat it as the first symbol of the reversed second half and pop the matching top while entering q2. Thus the displayed blanks are (q1,aa) and (q2,ε) for input a/top a, and (q1,bb) and (q2,ε) for input b/top b.

Those fillings alone do not recognize all even palindromes. The paper omits the mixed push transitions δ(q1,a,b)={(q1,ba)} and δ(q1,b,a)={(q1,ab)}. With rightmost stack top, ba means retain b and push a. For example abba requires pushing b over a; it is rejected if the missing transitions are absent. This is a defect in the printed specification, not an additional blank that can be silently filled.

With these two additional rules, q1 pushes an arbitrary nonempty first half. It switches to q2 only while reading and popping a matching character, then q2 can only pop further matching characters. Finally it removes Z by ε. Acceptance requires both empty stack and exhausted input. The first symbol must be pushed, so the empty word cannot be accepted; each push corresponds to exactly one later matched input, enforcing even length. The accepted strings are exactly wwR with nonempty w. No literal filling of just the four displayed blanks repairs the missing mixed cases.

Original paper, page 8

Report issue

A conversion impossible in general

Pushdown Automata

Question 1.16, GATE 1994: Which equivalent-machine conversion is impossible in general: regular grammar→CFG, NFA→DFA, NPDA→DPDA, or nondeterministic TM→deterministic TM?
Tap to enlarge
Your answer
Answer & solution

Answer: C (no official key was published)

Every regular grammar is already a restricted CFG, and the subset construction converts NFAs to equivalent DFAs. A deterministic TM can simulate all branches of a nondeterministic TM by dovetailing, preserving recognition power. But deterministic context-free languages are strictly fewer than context-free languages. For example unmarked palindromes over a two-letter alphabet are context-free but not deterministic context-free. Hence some NPDAs have no equivalent DPDA at all, so a general conversion cannot exist.

Original paper, page 2