First time here? Checkout the FAQ!
+1 vote

I am getting a) as ans. Plz tell how C?

asked in DS by Veteran (51.8k points)   | 66 views

Initially queue contains elements like 6,8,9,2

I)while statement is true.

II)dequeue from queue and push into stack until queue becomes enpty.

stack values are from top to bottom in order 2,9,8,6.//after completion of first while loop

III)2nd while loop pop one value from stack and enqueue into queue until stack becomes empty.

initially pop top value from stack i.e)2 and enqueue into queue.

after 2nd while loop false contents of queue is 2,9,8,6.

Hence it reverses the elements in queue

yes tnks

1 Answer

0 votes
Yes, answer will be C .
answered by (295 points)  
Top Users Feb 2017
  1. Arjun

    5502 Points

  2. Bikram

    4266 Points

  3. Habibkhan

    3972 Points

  4. Aboveallplayer

    3046 Points

  5. Debashish Deka

    2646 Points

  6. sriv_shubham

    2328 Points

  7. Smriti012

    2270 Points

  8. Arnabi

    2134 Points

  9. sh!va

    1926 Points

  10. mcjoshi

    1752 Points

Monthly Topper: Rs. 500 gift card

20,934 questions
26,054 answers
22,209 users