Write a C function that reverts a queue.


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

Back to the list of exercises
Looking for a more challenging exercise, try this one !!
Static Binary Search Trees