LOGBOOK

HELP

Quiz Entry - updated: 2026.09.29

What is the Queue ADT, and what are its operations?

A queue stores objects in first-in, first-out (FIFO) order: enqueue(o) adds at the rear, dequeue() removes and returns the element at the front. Helpers are first(), size() and isEmpty(); dequeue() and first() on an empty queue return null.

Think of a queue at a counter: newcomers join at the back, and the person served next is the one who has waited longest.

Operation What it does
enqueue(o) insert o at the rear
dequeue() remove and return the element at the front
first() return the front element without removing it
size() number of stored elements
isEmpty() whether any elements are stored

The difference from a stack is where elements leave. A stack adds and removes at the same end, so the newest element comes out first. A queue adds at one end and removes at the other, so the oldest comes out first.

Go deeper:

From Quiz: ADS / Linear Data Structures: Lists, Stacks, Queues, Deques, Iterators | Updated: Sep 29, 2026