Question: Following is a C like pseudo-code of a function that takes a queue as an argument and uses a stack S to do the processing.

Following is a C like pseudo-code of a function that takes a queue as an argument and uses a stack S to do the processing.

void fun (Queue *Q) { to S Stack S; // Say it

creates an empty stack S // Run while Q is not empty

What does the above function do in general?
A. Removes the last from Q
B. Keeps the Q the same as it was before the call
C. Makes Q empty
D. Reverses the Q

void fun (Queue *Q) { to S Stack S; // Say it creates an empty stack S // Run while Q is not empty while (!isEmpty (Q)) { // deQueue an item from Q and push the dequeued item push (&S, deQueue (Q)); } // Run while Stack S is not empty

Step by Step Solution

3.40 Rating (156 Votes )

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock

D Explanation The function takes a queue Q as an ... View full answer

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 Data Structures and Other Objects Using Java Questions!