Use the methods for stacks and queues developed in the course to write the following function: "Move all the entries from a Stack into a Queue". 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(stack *s, queue *q)
{
element e;
while(Top(*s,&e) && EnQueue(q,e) && Pop(s));
}
Back to the list of exercises
Looking for a more challenging exercise, try this one !!
Implementing a queue using two stacks