Queue
A queue is a data structure that is somewhat like a stack, except that in a queue the first item inserted is the first to be removed (First-In-First-Out, FIFO), while in a stack, as we've seen, the last item inserted is the first to be removed (LIFO).
Element access and deletion are restricted to the first element in the sequence, which is called the front of the queue, and
Element insertion is restricted to the end of the sequence, which is called the rear of the queue.
Enqueue(e):
Insert element e at the rear of the queue (end).
Dequeue():
Remove and return from the queue the object at the front; an error occurs if the queue is empty.
Comments
Post a Comment