View on GitHub

Bearded-android-docs

Queue

Download this project as a .zip file Download this project as a tar.gz file

Created Tuesday 17 December 2013

The queue is a FIFO data structure---first in/first out. Items are put in the end of the queue and are removed from the head of the queue. Think of a line at a bank.

Java has a Queue<E> interface as well as some concrete classes (not limited to):

How to Implement a Queue using a Stack

Stack A: head -> | 1 | 2 | 3 | 4 | 5 | <-tail

Stack B: head -> | 5 | 4 | 3 | 2 | 1 | <- tail

The items are now in reverse order so you can pop them from Stack B.

#


No backlinks to this page.
comments powered by Disqus