Skip to content

Lists, stacks and queues

Queues

Lessons on this topic

Intermediate · 25 minYou are hereRead

Queues

A queue takes items at the back and gives them out at the front, first in, first out. In a plain array the front creeps forward and the cells behind it are lost; on linked nodes they are not.

Intermediate · 25 minYou are hereRead

Circular queues

Letting head and tail wrap round to cell 0 turns a fixed array into a ring buffer, where the two ends chase each other for ever and no cell is ever lost.

Intermediate · 25 minYou are hereRead

Double-ended queues

A deque adds and removes at both ends. That is exactly what keeps the largest value of a sliding window at hand: n values, at most 2n deque operations.

Intermediate · 25 minYou are hereRead

Priority queues

A priority queue always hands out the most urgent item next. On a plain array, one of its two operations has to scan or shift; the heap fixes that later.

Phasorium

Account

Sign inWith Google, GitHub or your email

Subjects

Site

Look