Question: An implementation of a queue Q , using stacks S 1 and S 2 , is given below void insert ( Q , x )

An implementation of a queue Q, using stacks S1 and 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. Which one of the following is true for all m and n?
Group of answer choices
n+m<=x<2n and 2m<=y<=n+m
2m<=x<2n and 2m<=y<=n+m
2m<=x<2n and 2m<=y<=2n
n+m<=x<2n and 2m<=y<=2n

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Databases Questions!