Skip to lecture
Nova

Queues: first in, first out

Explore a short lecture, follow its citations and try a question before bringing your own material.

This is a Nova-authored demonstration with fixed answer checks. Your sample answer is temporary and does not affect your study history.

Source

1. The queue rule

A queue holds items in order. Enqueue adds an item at the back. Dequeue removes the item at the front.

The first item added is the first removed: first in, first out (FIFO). Removing the most recently added item instead would follow a stack’s last-in, first-out rule.

2. Follow the items

Start with A at the front, followed by B, then C at the back. Dequeue once, then enqueue D.

Queue contents from front to back
OperationContentsRemoved
StartA, B, CNone
DequeueB, CA
Enqueue DB, C, DNone

B is now at the front. D joined at the back without moving ahead of B or C.

Authored for this example. No university material or private uploads are used.

Note

Enqueue at the back; dequeue from the front. Adding a new item preserves the order of items already waiting.

Read source §1: The queue rule

Prepared sample Note. In your workspace, your own Notes stay with their lecture.

Try a question

After the operations in source §2, which item will the next dequeue remove?