Solve 2 2Using the basic queue and stack operations write an
Solve 2
2.Using the basic queue and stack operations, write an algorithm to reverse the elements in a queue. (10 pts)
HINT: Queue member functions: {Add_Q,Remove_Q,Empty}, Stack member functions: {push,pop,empty}
Solution
Algo REVERSE
1. Begin
2. If (Empty) //this function returns true is queue is empty
    printf(\"no element in queue\")
3. While (!Empty)
 a. int val = Remove_Q //this function removes the front element of the queue
 b. push(val) // this function adds the removed element of queue at the top of the stack
4. While (!empty) // this function checks if there is any element in the stack
    a. int val = pop // this function removes the top element of the stack
    b. Add_Q(val) // this function adds the removed element from stack at the rear of the queue
5. printf(Q); // prints all the elements of the queue
6. End

