Skip to main content

You are not logged in. Your edit will be placed in a queue until it is peer reviewed.

We welcome edits that make the post easier to understand and more valuable for readers. Because community members review edits, please try to make the post substantially better than how you found it, for example, by fixing grammar or adding additional resources and hyperlinks.

Required fields*

12
  • 17
    A queue is typically referring to a FIFO structure while the stack is a LIFO structure. The interface for LinkedList in Java is that of a deque (double ended queue) which allows both FIFO and LIFO access. Try changing programming to the Queue interface rather than the LinkedList implementation. Commented Jun 16, 2015 at 20:12
  • 13
    The more usual problem is to implement a queue using two stacks. You might find Chris Okasaki's book on purely functional data structures interesting. Commented Jun 17, 2015 at 0:21
  • 3
    Building off what Eric said, you can sometimes find yourself in a stack based language (such as dc or a push down automaton with two stacks (equivalent to a turing machine because, well, you can do more)) where you may find yourself with multiple stacks, but no queue. Commented Jun 17, 2015 at 2:04
  • 1
    @MichaelT: Or you can also find yourself running on a stack based CPU Commented Jun 17, 2015 at 3:22
  • 11
    "A stack is a (LIFO) queue"... uhm, a queue is a waiting line. Like the line for using a public restroom. Do the lines you wait in ever behave in a LIFO fashion? Stop using the term "LIFO queue", it's nonsensical. Commented Jun 17, 2015 at 7:25