0

Consider the language of even-length palindromes $L = \{ WW^R \mid W \in \{0,1\}^* \}$. This language is surely context free and I need an NPDA to recognize it.

But, what if we replace the stack with a queue which supports insert and delete operations? Can a queue automaton accept $L$?

Raphael
  • 72,336
  • 29
  • 179
  • 389
Garrick
  • 462
  • 1
  • 7
  • 22

1 Answers1

9

The construction of a PDA except with a FIFO instead of a LIFO data structure attached can mimic any single tape TM as follows: it keeps the cell contents in the queue along with two special markers for the end of the tape and for the head of the TM. Every time you make a move, you just go through the entire queue and re-push everything you pop, making whatever slight modification in head position and tape contents you require.

So this is computationally equivalent to a Turing Machine, so in particular it can recognize $L = \{ww^R \mid w \in \{0, 1\}^*\}$.

MT_
  • 463
  • 2
  • 9
  • Thanks for the answer ! Can you elaborate more on the part how it mimics TM ? – Garrick Oct 25 '16 at 16:09
  • One more query - what if the language was L = { WW | W belongs to (0,1)* } ? – Garrick Oct 25 '16 at 16:23
  • @Willturner I Think filling in the details will be a good exercise. As per the second question, the answer is of course yes -- we can easily design a TM (with multiple tapes perhaps to make it even easier; $k$-tape TMs and single-tape TMs define the same class of languages) that accepts $L$. – MT_ Oct 25 '16 at 17:57
  • Okk , I'll see that in detail. Just a doubt - Is it ok, to say that queue automaton recognizes this language and hence it is Recursively enumerable language and not CFL, which it was before when we used stack? – Garrick Oct 25 '16 at 19:19
  • @Willturner Please stop vampiring. You've been warned before. Take the answers to get, absorb them, think on them. If you encounter new questions, do your own research, and possible post a new question. Don't pester answerers in the comments! – Raphael Oct 25 '16 at 22:22
  • 1
    " Is it ok, to say that queue automaton recognizes this language and hence it is Recursively enumerable language and not CFL, which it was before when we used stack? " -- no, not at all. The definition of CFL does not change just because you investigate some other machine model. – Raphael Oct 25 '16 at 22:23