• edited by
14,174 views
43 43 votes

Consider the pushdown automaton (PDA) below which runs over the input alphabet $(a, b, c)$. It has the stack alphabet $\{Z_0, X\}$ where $Z_0$ is the bottom-of-stack marker. The set of states of the PDA is $(s, t, u, f\}$ where $s$ is the start state and $f$ is the final state. The PDA accepts by final state. The transitions of the PDA given below are depicted in a standard manner. For example, the transition $(s, b, X) \rightarrow (t, XZ_0)$ means that if the PDA is in state $s$ and the symbol on the top of the stack is $X$, then it can read b from the input and move to state $t$ after popping the top of stack and pushing the symbols $Z_0$ and $X$ (in that order) on the stack.

$(s, a, Z_0) \rightarrow  (s, XXZ_0)$
$(s, \epsilon, Z_0) \rightarrow  (f, \epsilon)$
$(s, a, X) \rightarrow  (s, XXX)$
$(s, b, X) \rightarrow  (t, \epsilon)$
$(t, b, X) \rightarrow  (t,\epsilon)$
$(t, c, X) \rightarrow  (u, \epsilon)$
$(u, c, X)  \rightarrow  (u, \epsilon)$
$(u, \epsilon, Z_0) \rightarrow  (f, \epsilon)$

The language accepted by the PDA is

  1. $\{a^lb^mc^n \mid  l = m = n\}$
  2. $\{a^l b^m c^n \mid l = m\}$
  3. $\{a^lb^mc^n \mid 2l = m + n\}$
  4. $\{a^lb^mc^n \mid m = n\}$

5 Answers

Best answer
53 53 votes
For every $a$ we put two $X$ in stack [at state $s$]

After that for every $b$ we pop out one $X$    [reach to state $t$ ( getting $b$ after $a$) ]

After that for every $c$ we pop out one $X$    [reach to state $u$ (getting $c$ after $b$)]

If all $X$ are popped  out  then reached to final state $f$ , mean for every $b$ there is $a$, for every $c$ there is $a$ .

$a$ was followed by $b$ and $b$ was followed by $c$ [ state $s$ to $t , t$ to $u , u$ to $f$, final]

means sum of no of $b$'s  and no of $c$'s $=$ twice of no of $a$'s      [ one $a$ for one $b$ , one $a$ for one $c$ ]

i.e. $\{a^lb^mc^n \mid 2l = m + n\}$

Correct Answer: $C$
• edited by
1 flag:
✌ Low quality (Sameer Bawane “But what if l=2 such that m0 and n=4 in that case Option C fails as we need at least 1 b to move to State u to get X's popped out”)
2 2 votes

clearly, after reading "a"  XX add on to the stack and after reading "b" or  "c" X get pop from stack. hence option(C) is our answer i.e 2l=m+n.

1 1 vote

PDA for the given CFG is

consider ^ to be epsilon

 

             ip: (a, Z0 -> XXZ0 )  | (a, X -> XXX)

                |

--------->( s ) ----  ip: (^, Z0 -> ^ )  ------------------>( ( f ) )

                |                                                               ^

                |                                                                |

                | ip: ( b, X -> ^ )                                       | ip: ( ^, Z0 -> ^)

                |                                                                |

                v                                                               |

              ( t )  ----  ip:( c, X -> ^ )   ------------------> ( u )

                ^                                                              ^

                 |                                                              |

           ip: b, X -> ^                                        ip: c, X -> ^

 

Strings that are accepted are { ^ , abc , aabbbc , aabccc , aabbcc ,...............}

For a string S = aabccc

Stack = [Z0 ] ( Initial State )

i) For ip = a

       Stack = [ Z0 ] ==> pop 'Z0' and add 'XXZ0' to the stack.

       Stack = [ X , X , Z0]

       Transition : S --> S.

ii) For ip = a

    Stack = [ X , X , Z0 ] ==> pop 'X' and add 'XXX' to the stack.

    Stack = [ X , X , X , X , Z0 ]

    Transition : S --> S.

iii) For ip = b

     Stack = [ X , X , X , X , Z0 ] ==> pop 'X' and add nothing to the stack.

     Stack = [ X , X , X , Z0]

     Transition : S --> t.

iv) For ip = c

     Stack = [ X , X , X , Z0 ] ==> pop 'X' and add nothing to the stack.

     Stack = [ X , X , Z0 ]

     Transition : t --> u.

v) For ip = c

    Stack = [ X , X , Zo ] ==> pop 'X' and add nothing to the stack.

    Stack = [ X , X , Z0 ]

    Transition : u --> u.

vi) For ip = c

    Stack = [ X , Zo ] ==> pop 'X' and add nothing to the stack.

    Stack = [ Z0 ]

    Transition : u --> u.

vii) For ip = ^

    Stack = [ Zo ] ==> pop 'Z0' and add nothing to the stack.

    Stack = [  ]

    Transition : u --> f.

As the stack is empty and also we reached the final state 'f' the string is accepted.

S = a**2 b**1 c**3

l = 2

m = 1

n = 3

==> 2l = m+n 

       2(2) = 1+3

      Therefore option C is correct.

0 0 votes
ans (C)...
0 0 votes

option C

For 1 a, 2 x is pushed into the stack 

for 1 b, 1 x is popped 

then for 1 c, 1 x is popped

so string will consist of a followed by b followed by c. there is no way we can make c count as zero as at stage t, (b,E/#) moved is not defined so PDA will die here, so c will come in string.

Answer:
Position:
Show:

Related questions

41 41 votes
4 answers 4 answers
25.1k
25.1k views
Ishrat Jahan asked Oct 31, 2014
25,145 views
Which of the following languages is accepted by a non-deterministic pushdown automaton (PDA) but NOT by a deterministic PDA?$\{a^nb^nc^n \mid n ≥ 0\}$$\{a^lb^mc^n \mid l ...
56 56 votes
4 answers 4 answers
18.2k
18.2k views
Ishrat Jahan asked Nov 1, 2014
18,246 views
Let $L$ be a regular language. Consider the constructions on $L$ below:$\text{repeat} (L) = \{ww \mid w \in L\}$$\text{prefix} (L) = \{u \mid \exists v : uv \in L\}$$\tex...
40 40 votes
3 answers 3 answers
16.0k
16.0k views
Ishrat Jahan asked Nov 1, 2014
16,047 views
Let $L$ be a regular language. Consider the constructions on $L$ below:repeat $(L) = \{ww \mid w \in L\}$prefix $(L) = \{u \mid ∃v : uv \in L\}$suffix $(L) = \{v \mid ...
64 64 votes
5 answers 5 answers
14.5k
14.5k views
Ishrat Jahan asked Oct 31, 2014
14,468 views
For a state machine with the following state diagram the expression for the next state $S^+$ in terms of the current state $S$ and the input variables $x$ and $y$ is$S^+ ...