Skip to content

Introduction to Stacks and Queues

In many applications we have collections of objects we want to maintain. The operations for these objects are simple.

We would want to:

  • Add something to a collection
  • Remove something from a collection
  • Iterate through the objects in a collection and perform some operation on them
  • Test if an object is empty

Where a Stack and a Queue fundamentally differ is in the way we remove objects, in a stack we take out the item that was most recently added (push (insert) and pop(remove)) where as with a queue we examine the item least recently added (enqueue (insert) and dequeue(remove)).