What does the following recursive function do on a queue? Do(Q) { if…

What does the following recursive function do on a queue? 

Do(Q)

{

    if (!isEmpty(Q))

    {

        temp = dequeue(Q)

        Do(Q)

        enqueue(temp, Q)

    }

}

  1. A.

    Implementation of stack using queue

  2. B.

    Reversing elements of queue

  3. C.

    Printing elements of queue

  4. D.

    Printing elements of queue in reverse without changing the queue contents

Attempted by 604 students.

Sign up free to check your answer

Sign up free

Explore the full course: Gate Guidance By Sanchit Sir

Loading lesson…