14.4 Implementing a Queue Using a Linked List
Imagine a line of people at an automated teller machine, or ATM, waiting to withdraw cash. The person at the front of the line is using the ATM. When a new customer arrives, the customer goes to the back of the line. As customers use the ATM, they exit the line, and the next customer moves to the front of the line. Thus, customers use the ATM in the order of their arrival times. We call this pattern “first in, first out,” or FIFO.
A queue is a linear data structure that organizes items in a first in, first out manner.
Figure 14.9 shows a queue of people at an ATM. The person at the front of the queue arrived first and will use the ATM first. The person at the back arrived last and will use the ...
Get Java Illuminated, 5th Edition 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.