An implementation of a queue q using two stacks s1 s2 is


An implementation of a queue Q using two stacks S1 S2 is given below 
void insert(Q,x){ 
PUSH(S1,x); 

void delete (Q) 

if (stack -empty (S2)) then 
if(stack -empty (S1)) 
then 

print ("Q is empty"); 
return; 

else while (!(stack-empty)(S1))){ 
x= pop(S1); 
push(S2,x); 

x=pop(S2); 

Let n insert and M(«n) delete operations be performed in an arbitrary order on an empty queue Q. let x and y be the number of push and pop operations performed respectively in the process, true equation for all m and n?

Solution Preview :

Prepared by a verified Expert
Computer Engineering: An implementation of a queue q using two stacks s1 s2 is
Reference No:- TGS01266583

Now Priced at $12 (50% Discount)

Recommended (91%)

Rated (4.3/5)