Queue
Queue is an interactive experiment in Data Structures, a free simulation from StudyFi Lab that runs right in your browser.
A queue works like a line at a till: new items join at the back (enqueue, the rear pointer) and leave from the front (dequeue, the front pointer), so first in, first out (FIFO). In an array it is stored as a circular buffer: both pointers wrap from the last slot back to slot 0, so enqueue and dequeue take O(1). Queues run printer jobs, server requests and video buffering.
Try this: Turn on the circular view, enqueue six numbers, dequeue four and enqueue four more — watch rear wrap from slot 7 to slot 0.
Frequently asked questions
What does the “Queue” experiment show?
A queue works like a line at a till: new items join at the back (enqueue, the rear pointer) and leave from the front (dequeue, the front pointer), so first in, first out (FIFO). In an array it is stored as a circular buffer: both pointers wrap from the last slot back to slot 0, so enqueue and dequeue take O(1). Queues run printer jobs, server requests and video buffering.
How do I try “Queue”?
Turn on the circular view, enqueue six numbers, dequeue four and enqueue four more — watch rear wrap from slot 7 to slot 0.
Studying for a test?
Upload your notes and StudyFi turns them into flashcards, tests and podcasts.