Use the methods for stacks and queues developed in the course to write the following function: "Use a local Queue to reverse the order of all the entries in 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
![](images/star2.png)
Video recording
This exercise is mostly suitable for students
void reverse(stack *s)
{
queue q;
element e;
q=CreateQueue();
while(Top(*s,&e) && EnQueue(&q,e) && Pop(s));
while(Front(q,&e) && Push(s,e) && DeQueue(&q));
}
Back to the list of exercises
Looking for a more challenging exercise, try this one !!
![](images/star5.png)