What does the following function do in general? void fun(Queue *Q) { Stack S;…

What does the following function do in general?

void fun(Queue *Q)

{

    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 to S

        push(&S, deQueue(Q));

    }

    // Run while Stack S is not empty

    while (!isEmpty(&S))

    {

        // Pop an item from S and enqueue the popped item to Q

        enQueue(Q, pop(&S));

    }

}



  1. A.

    Removes the last from Q


  2. B.

    Keeps the Q same as it was before the call


  3. C.

    Makes Q empty


  4. D.

    Reverses the Q


Attempted by 530 students.

Sign up free to check your answer

Sign up free

Explore the full course: Gate Guidance By Sanchit Sir

Loading lesson…