r/programming • • May 08 '15

Five programming problems every Software Engineer should be able to solve in less than 1 hour

https://blog.svpino.com/2015/05/07/five-programming-problems-every-software-engineer-should-be-able-to-solve-in-less-than-1-hour
2.5k Upvotes

2.1k comments sorted by

View all comments

Show parent comments

0

u/[deleted] May 08 '15

[deleted]

1

u/OneWingedShark May 08 '15

But can you implement a stack with two queues?
No. (Proof of this assertion is left as an exercise to the reader.)

2

u/UNWS May 08 '15

You can implement a stack with just 1 queue. So your assertion is wrong.

1

u/OneWingedShark May 08 '15

A Queue is a first-in/first-out structure, a stack is a first-in/last-out structure -- because of this property two stacks can emulate a queue (FILO -> FILO = FIFO), you cannot do the same with a queue because there is no reordering (FIFO -> FIFO /= FILO).

If I'm wrong, prove it.

→ More replies (2)