487 views

1 Answer

Best answer
3 votes
3 votes

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

1 votes
1 votes
1 answer
2
radha gogia asked Jul 24, 2018
1,405 views
Suppose one character at a time comes as an input from a string of letters . There is an option either to 1) print the incoming letter or to 2) put the incoming letter on...
2 votes
2 votes
1 answer
3
Tuhin Dutta asked Dec 9, 2017
593 views
Let's consider we have a stack with three operations defined on it:: Push,Pop, PeekWe have to print "ABCACBA" using the above operations.Give the min no of operations for...
0 votes
0 votes
1 answer
4
Abhrajyoti00 asked Oct 29, 2022
741 views
Can there be “Stack Overflow” in Linked list Implementation of stack? If Yes, how?