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?

  1. A. 11
  2. B. 6
  3. C. 8
  4. 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

Exams that ask this topic