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.
Lists, stacks and queues
Intermediate · 25 minYou are hereRead
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
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
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
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.
Related topics