Let Q denotes a queue and S denotes a stack with n elements and k is any integer less than n. Enqueue inserts an element at the end while Dequeue operation deletes an element from the front of the queue. The given code ________
void fun(Q, k)
{
if(Q == NULL || k > n)
return -1;
else
{
for(i = 0; i
push(S, Dequeue(Q);
while !(isstackempty(S))
{
Enqueue(Q, pop(S));
}
for(i = 0; i < n – k, i++)
Enqueue(Q, Dequeue(Q));
}
}1
Reverses the elements in a queue.
2
Stores k elements in stack and returns top of the stack.
3
Reverses the first k elements of the queue.
4
Stores k elements in stack and returns middle element of the stack.