Queues

The last element you push onto a stack will be the first element that’s popped off the stack. A stack is a last-in, first-out (or LIFO) data structure.

In contrast, a queue is a first-in, first-out (or FIFO) data structure. The first element you enqueue will be the first element you dequeue.

To understand the concept, think of an everyday queue. So, say you are standing in line at the bank. The first person in the line will be the first person the bank teller calls to the window. The computer-science concept of queues is an abstraction of the queues that we experience in everyday life.

Here is my C++ implementation of the queue. It is up at my GitHub.

Advertisements

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s