Chapter 5

Queues

5.1 Interface and Linked Implementation

The close counterpart of a stack is a queue. In (primarily) British usage, a queue is a waiting line. In computer science, a queue is a data structure that acts like a waiting line, in which items are removed from the front of the line, and new items are added to the rear of the line. A queue is a first-in, first-out (FIFO) data structure, because the first element in will be the first one out.

image

Adding to the rear of a queue is called enqueuing, and removing from the front of a queue is called dequeuing (pronounced “DQ-ing”). The front is drawn on the left here to match the linked lists ...

Get A Concise Introduction to Data Structures using Java now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.