63 796
Assignments Done
99,4%
Successfully Done
In August 2018

Answer to Question #78885 in C for Sam

Question #78885
What is the top element in the stack S.
Stack(S); //create a stack S
Queue(Q); //create a queue Q
Push (S,1); Push(S,2);
Push (S,3); Push(S,4);
Enqueue(Q,5); Enqueue(Q,6);
For (i=1) to 4) {
X=Pop (S);
Enqueue(Q,x);
}
For (i=1 to 6) {
Z=Dequeue (Q);
Push(S,x);
}
Expert's answer
There are two possible answers:
1. 1, If in the second cycle there is a misprint ( Z=Dequeue (Q); Push(S,x); ), where Z should be pushed
2. 4, If everything is correct, x is last popped element from previous cycle

Need a fast expert's response?

Submit order

and get a quick answer at the best price

for any assignment or question with DETAILED EXPLANATIONS!

Comments

No comments. Be first!

Leave a comment

Ask Your question

Submit
Privacy policy Terms and Conditions