Thursday, September 13, 2012

Implementing Queue Using Stack:

Goforexam.in | Guide for Placements, Aptitude, Interviews, Projects.....: Implementing Queue Using Stack:
Question: How would you use stacks to implement a queue? Answer: So how could we go about doing this? What if we used two stacks and used one as the incoming stack and the other as the outgoing stack? A queue is a FIFO structure, so when we enqueue something, we need to make sure that it does not get popped off before something that was already there. Similarly, when we dequeue something, we have to make sure that elements...
Read more ...

No comments:

Post a Comment

comment