Use the methods for stacks and queues developed in the course to write the following function: "Move all the entries from a Queue onto a Stack". In writing your function, be sure to check for empty and full structures as appropriate. Your function may declare other, local structures as needed.


Difficulty level
Video recording
This exercise is mostly suitable for students
void move(queue *q, stack *s)
{
    element e;
    while(Front(*q,&e) && Push(s,e) && DeQueue(q));
}

Back to the list of exercises
Looking for a more challenging exercise, try this one !!
Hashing using linear probing