A queue is a linear data structure which models real world queues by having two primary operations, namely *enqueue
* and *dequeue*
In a FIFO data structure, the first element added to the queue will be processed first
.
As shown in the picture above, the queue is a typical FIFO data structure. The insert operation is also called enqueue (поставить в очередь) and the new element is always added at the end of the queue
. The delete operation is called dequeue (снять с очереди). You are only allowed to remove the first element
.
The FIFO property of a queue causes it to operate like a line of customers waiting to pay a cashier. The queue has a head and a tail. When an element is en- queued, it takes its place at the tail of the queue, just as a newly arriving customer takes a place at the end of the line. The element dequeued is always the one at the head of the queue, like the customer at the head of the line who has waited the longest.
Queues and Stacks can be effectively implemented using either arrays or linked lists. The key issue is whether an upper bound on the size of the container is known in advance, thus permitting the use of a statically-allocated array.
There does not seem to be consistent terminology for inserting and removing elements from queues.
Enqueue = Adding = Offering
Dequeue = Polling = Removing (means removing from the front of the queue unless you are tolled otherwise)
x
most recently added elements.