edited by
2 flags 88,553 views
71 71 votes

Let $M = (K, Σ, Г, Δ, s, F)$ be a pushdown automaton, where

$K = (s, f), F = \{f\}, \Sigma = \{a, b\}, Г = \{a\}$ and
$Δ = \{((s, a, \epsilon), (s, a)), ((s, b, \epsilon), (s, a)), (( s, a, a), (f, \epsilon)), ((f, a, a), (f, \epsilon)), ((f, b, a), (f, \epsilon))\}$.

Which one of the following strings is not a member of $L(M)$?

  1. $aaa$
  2. $aabab$
  3. $baaba$
  4. $bab$
  • 🚩 Edit necessary | 👮 Sus_Rat | 💬 “In the end of the page Answer is written B but the answer is option D”
  • 🚩 Edit necessary | 👮 0shan | 💬 “Correct The Answer.”

10 Answers

Best answer
74 74 votes

Answer is D.

First of all the transition $(s, a, \epsilon) , (s, a)$ means on input $a$, the PDA stays in same state and pushes $a$ on stack irrespective of the current stack top value ($\epsilon$ means read nothing from stack and is not the stack bottom symbol). Like $epsilon$ moves in NFA, this makes the given PDA non-deterministic. 

The language is like:

In start state $a$'s or $b$'s come, just push $a$'s on stack except for the last $a$ which is used to shift from "start state" to "final state" (non-determinism) without consuming any stack symbol. Now in "final state", for equal no's of $a$'s and $b$'s just pop $a$'s from stack. This is the interpretation of transitions given for the language. So, it accepts strings of the form $wab^n$ where $w \in (a+b)^*$ and $n < |w|.$ This is violated only for option D and hence it is not in $L.$ 

For any string push 'a' on stack except for the final 'a' which will cause a move to final state and a pop. Then for every 'b', stack is popped. If stack becomes empty before string end, we reach a dead state and string is rejected. Else, accepted. 

  1. $aaa $: push $a$....push $a$....pop $a\qquad$Final State, ACCEPTED
  2. $aabab$: push $a$....push $a$...push $a$...pop $a$...pop $a$$\qquad$Final State, ACCEPTED
  3. $baaba$ : push $a$...push $a$....push $a$....push $a$....pop $a$$\qquad$Final State, ACCEPTED
  4. $bab$ : push $a$....pop $a$....dead state$\qquad$ REJECTED

PS: This PDA is an NPDA and acceptance is by FINAL State. If no valid move is given for any state in NPDA, then the corresponding transition goes to a dead state. 

edited by
20 20 votes

First have a look on the PDA for the given transitions:

now here transition ((s,a,ϵ),(s,a)) implies reading input symbol 'a' in state 's' we have to move 's' having any symbol on the top of stack...epsilon here implies "anything on the TOS".

Now observe the PDA carefully, it is saying that in the starting you have to push one 'a' for each of 'a' and 'b'. And in the end you have to pop one 'a'  by one 'a' or one 'b'. Thus the count of a's and b's  in first half of the string should be equal second half of string. Now to move from first half to the second half we are required one 'a' i.e. moving from s to f.

So, all odd strings in which 'a' is the middle symbol will be accepted. For eg. aab a bbb

Thus, in our question option B. is (aa b ab) having 'b' in the middle...and thus can't be accepted.

17 17 votes

@Arjun Sir pls check this ans

1.((s, a, ε)---> (s, a))

2.((s, b, ε)---> (s, a))

3.((s, a, ε)---> (f, ε))

4.((f, a, a)---> (f, ε))

5.((f, b, a)---> (f, ε))

option A---  aaa

 (s,a,ε)---transition 1-->(s,a)

 (s,a,a)---transition 3-->(f,a) //just consume the input and move to final state

                                                      don't change stack symbol

 (f,a,a)---transition 4-->(f,ε) //pop the topmost symbol

  since the stack is empty now and string is also complelety read so it is accepted

option C---  baaba

 (s,b,ε)---transition 2-->(s,a) //read symbol b and push a onto stack

                      

 (s,a,a)---transition 1-->(s,a) // just consume the input without seeing the stack symbol

    and push a onto stack

(s,a,ε)---transition 3-->(f,a)// just consume the input without seeing the stack symbol

    and move to final state

 (f,b,a)---transition 5-->(f,ε) //pop the top of stack

 (f,a,a)---transition 4-->(f,ε) //pop the top of stack 

  since the stack is empty now and string is also complelety read so it is accepted

option D---  bab

 (s,b,ε)---transition 1-->(s,a)

 (s,a,a)---transition 3-->(f,a) //just consume the input and move to final state

                                                 don't change stack symbol

 (f,a,a)---transition 4-->(f,ε) //pop the topmost symbol

  since the stack is empty now and string is also complelety read so it is accepted

Option B—aabab

 (s,a,ε)---transition 1-->(s,a) //read symbol a and push a onto stack

 (s,a,a)---transition 3-->(s,a) // just consume the input without seeing the stack symbol

and move to final state

(s,b,a)---transition 5-->(f, ε)// pop the top of stack

Now we are stuck as no move is defined so this is not accepted by PDA

7 7 votes

Context Free Language can be accepted either by empty stack or final state.

Given PDA is non-deterministic due to on state 's' and input 'a' two possibilities exist. (i.e., either push 'a' into the stack without seeing the top of the stack or pop 'a' only from the stack).

Note that, (s,a,a)  ---> (f,epsilon) is the only transition that lead to final state. After that it is popping 'a' from stack for every 'a' or 'b' of input.

Hence, there are two possibilities after reaching to the final state:- 

  1. no.of remaining symbols (consider only 'a' and 'b') in input string are less than (or equal) to the no.of symbols in the stack. Then we will end up with some symbols in stack. However, as we are in final state, and complete input string processed $\Rightarrow$ input string is accepted.
  2. no.of remaining symbols (consider only 'a' and 'b') in input string are grater than the no.of symbols in the stack. Then we will end up with some symbols in input string but stack is empty. There is no other transitions (except popping from stack) exist on final state, and input string is not completely processed $\Rightarrow$ input string is rejected.

Therefore we can conclude that input string should be something like : (X).a.(Y) and length of Y should be less than length of X.

Therefore pattern = (a+b)^m . a . (a+b)^n and m>n ---- 

[Note: 'a' is non-determinstically determined by PDA]

 

One possible doubt is : why not m $\geq$ n ?

We are sure about m>n. we need to understand what if m = n.

let consider this scinario : X part of the input string is processed. Therefore we have m symbols in stack and we need to process remaining input string. 
on processing 'a', as (s,a,a)  ---> (f,epsilon), one element is popped from stack and no push into the stack.


Therefore we have m-1 symbols in the stack. and we have to process Y part in the input string. As stack size is m-1, the remaining input string should be atmost m-1 size. Otherwise, input will be rejected.

Therefore m > n but not m $\geq$ n.

if we check the options one by one :-

  1. $aaa $: push $a$....push $a$....pop $a\qquad$Final State, ACCEPTED
  2. $aabab$: push $a$....push $a$...push $a$...pop $a$...pop $a$$\qquad$Final State, ACCEPTED
  3. $baaba$ : push $a$...push $a$....push $a$....push $a$....pop $a$$\qquad$Final State, ACCEPTED
  4. $bab$ : push $a$....pop $a$....dead state$\qquad$ REJECTED
6 6 votes
acc. to the transitions given, the machine will reach the final state.. only when stack contains null.. but the moment. input symbol b is provided..symbol a will be pushed in the stack.. so acc. to me.. neither of c) or d) is a member.
3 3 votes
The question above is wrong..

Instead of ((s,a,epsilon),(f,epsilon)) , it should be ((s,a,a),(f,epsilon)).
Answer:
Position:
Show:

Related questions

59 59 votes
5 answers 5 answers
12.2k
12.2k views
Ishrat Jahan asked Nov 2, 2014
12,239 views
Let $M=(K, Σ, \sigma, s, F)$ be a finite state automaton, where$K = \{A, B\}, Σ = \{a, b\}, s = A, F = \{B\},$$\sigma(A, a) = A, \sigma(A, b) = B, \sigma(B, a) = B \text{...
40 40 votes
5 answers 5 answers
14.6k
14.6k views
Ishrat Jahan asked Nov 1, 2014
14,610 views
Which one of the following regular expressions is NOT equivalent to the regular expression $(a + b + c)^*$?$(a^* + b^* + c^*)^*$$(a^*b^*c^*)^*$$((ab)^* + c^*)^*$$(a^*b^* ...
3 3 votes
1 answers 1 answer
3.9k
3.9k views
Ishrat Jahan asked Nov 2, 2014
3,899 views
Given below are several usages of the anchor tag in HTML.<A HREF = "http://www.gate.ac.in/HTML/BASIC/testpage.html">Test Me</A><A HREF = "/BASIC/testpage.html">Test Me</A...
1 1 vote
1 1 answer
2.6k
2.6k views
Ishrat Jahan asked Nov 2, 2014
2,635 views
Consider an XML file called intro.xml and a document type defintion (DTD) file intro.dtd as follows:intro.xml<?xml version = "1.0"? <!DOCTYPE myMessage SYSTEM "intro.dtd"...