in DS
486 views
1 vote
1 vote

in DS
486 views

1 Answer

3 votes
3 votes
Best answer

In the problem 4 conditions are given using those conditions have to perform stack operations.

Check options one by one and which one is violating above conditions.

Let me start from first 

1) Top(push(push($\epsilon$,X),Y)):

It can be rewritten as $Top(push(s,Y))$=Y.  using rule 4 with rule 2 [Here s=push($\epsilon ,X$)] 

2)pop(push($\epsilon ,X$))=$\epsilon$ .  using rule 3.

3)push(pop(push($\epsilon$,X)),Y):

it can be rewritten as push($\epsilon$,Y) it is a stack. using rule 2 with rule 3.

4) Pop(pop(push($\epsilon$,X))) =X  .

It can be rewritten as ${\color{Red} p}{\color{Red} o}{\color{Red} p}{\color{Red} ({\color{Red} \epsilon }}{\color{Red} )}$ !=X.

using rule 3.

Hence answer should be 4.

selected by

Related questions