GATE Computer ScienceVery hardGATE CS (PYQ pattern)
A nondeterministic PDA over {a, b, c} (acceptance by final state at the end of the input) guesses at the start whether to check #a = #b (then any number of c's may follow) or #b = #c (then any number of a's may precede). It accepts exactly the strings aⁱbʲcᵏ with i = j or j = k. How many such strings have length exactly 7?
- A. 11
- B. 6
- C. 8
- D. 20
Correct answer: C. 8
Count aⁱbʲcᵏ with i+j+k = 7: i = j gives j ∈ 0..3 with k = 7 − 2j; j = k similarly gives 4 strings; the string with i = j = k needs 3j = 7, impossible, so no overlap is removed: total 8.
More Theory of Computation questions
- A single-tape TM with blank B starts in q0 on the leftmost cell of the input 10111. Its rules (state, symbol) → (state, write, move) are…
- A TM (blank B, start q0 on the leftmost input cell, halting state qa) has rules δ(q0,0) = (q0,0,R); δ(q0,1) = (q0,1,R); δ(q0,B) =…
- A TM with rules δ(q0,a) = (q1,X,R); δ(q0,Y) = (q4,Y,R); δ(q1,a) = (q1,a,R); δ(q1,Y) = (q1,Y,R); δ(q1,b) = (q2,Y,R); δ(q2,b) = (q2,b,R)…
- A TM over {0, 1} (blank B, start q0 on the leftmost cell, accepts at qa, rejects by having no applicable rule) has rules: δ(q0,X) =…
- For the same TM with rules δ(q0,X) = (q0,X,R); δ(q0,0) = (q1,X,R); δ(q0,1) = (q2,X,R); δ(q0,B) = (qa,B,R); δ(q1,0) = (q1,0,R); δ(q1,X) =…
- L₁ is context-free, L₂ is regular and L₃ is deterministic context-free (all over the same alphabet Σ, complements taken w.r.t. Σ). Which…