GATE CSE
First time here? Checkout the FAQ!
x
+1 vote
59 views

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

asked in DS by Veteran (49.8k points)   | 59 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 Jan 2017
  1. Debashish Deka

    9614 Points

  2. sudsho

    5554 Points

  3. Habibkhan

    4878 Points

  4. Bikram

    4774 Points

  5. Vijay Thakur

    4498 Points

  6. Arjun

    4408 Points

  7. saurabh rai

    4236 Points

  8. Sushant Gokhale

    4112 Points

  9. Kapil

    3830 Points

  10. santhoshdevulapally

    3808 Points

Monthly Topper: Rs. 500 gift card

19,371 questions
24,203 answers
53,828 comments
20,370 users