Log In
15 votes
Give a deterministic PDA for the language $L=\{a^ncb^{2n} \mid n \geq 1\}$ over the alphabet $\Sigma = \{a,b,c\}$. Specify the acceptance state.
in Theory of Computation
retagged by

2 Answers

19 votes
Best answer

$L=\{a^n c b^{2n}\}$

Here, $\textbf{c}$ acts as center. Push $2$ $a$'s for each $\textbf{a}$  and after $\textbf{c}$ start popping an $\textbf{a}$ for each $\textbf{b}$. If stack is empty and string is finished we move to $q_2$ which is the acceptance state.

edited by
you can't set q1 as an accepting state because if suppose string is aacb then it will be accepted. So, you have to make one more state from q1 to  q2( i.e final state) for the (e, Zo / Zo).
@pooja khatri
  above diagram is  follow empty stack right??

  what about Final state diagram?
How is it following empty stack property? It has a Final state.
Sir,  I am confuse the main difference between empty stack and final state in PDA

In this video, he said that putting two 'a's' on reading one 'a' is not valid. Can someone please clarify I am confused. @Arjun @Saraswati Walujkar

1 vote

Two way to draw it

2 figure) For single  input a push two a's on stack for state 0 and when c comes then don't do anything and change the state to 1 now as b will come the then top of the stack will have a then pop the a's for b's ,so when stack becomes empty then on seeing the input Null we can accept it by changing state to 2 (final) state.

1 figure) by pushing a's then don't do anything as c comes and move to state to 1 now if b comes then top of stack has a, don't do anything for first b (move to state 2)then for second b pop  the a(move to state 3) repeat steps if there are more a's on the stack (as shown in figure,by moving from state 3 to state 2 ) otherwise accept it by moving from state 3 to 4.

Related questions

16 votes
4 answers
Consider the following languages: $L1=\left\{ww \mid w \in \{a,b\}^*\right\}$ $L2=\left\{ww^R \mid w \in \{a,b\}^*, w^R \text{ is the reverse of w} \right\}$ $L3=\left\{0^{2i} \mid \text{ i is an integer} \right\}$ $L4= \left\{ 0^{i^2} \mid \text{ i is an integer} \right\}$ Which of the languages are regular? Only $L1$ and $L2$ Only $L2, L3$ and $L4$ Only $L3$ and $L4$ Only $L3$
asked Sep 14, 2014 in Theory of Computation Kathleen 2.8k views
23 votes
2 answers
Construct DFA's for the following languages: $L=\left\{w \mid w \in \{a,b\}^*, \text{ w has baab as a substring } \right\}$ $L=\left\{w \mid w \in \{a,b\}^*, \text{ w has an odd number of a's and an odd number of b's } \right\} $
asked Sep 15, 2014 in Theory of Computation Kathleen 1.6k views
36 votes
1 answer
Consider the following problem $X$. Given a Turing machine $M$ over the input alphabet $\Sigma$, any state $q$ of $M$ and a word $w \in \Sigma^*$, does the computation of $M$ on $w$ visit the state of $q$? Which of the following statements ... correct? $X$ is decidable $X$ is undecidable but partially decidable $X$ is undecidable and not even partially decidable $X$ is not a decision problem
asked Sep 14, 2014 in Theory of Computation Kathleen 4.5k views
20 votes
4 answers
Given an arbitrary non-deterministic finite automaton (NFA) with $N$ states, the maximum number of states in an equivalent minimized DFA at least $N^2$ $2^N$ $2N$ $N!$
asked Sep 14, 2014 in Theory of Computation Kathleen 6k views