FIFO
First in, first out: the ordering rule of a queue, where the oldest item is always the next to leave.
In more detail
FIFO order is fair: nothing waits behind something that arrived later. Breadth-first search relies on it to visit vertices in order of distance from the start.
Example
Each Node.js event loop phase runs its callback queue in first in, first out order.Related terms
- queue — A collection where items leave in the order they arrived: first in, first out, like a line at a shop counter.
- LIFO — Last in, first out: the ordering rule of a stack, where the newest item is always the next to leave.
- task queue — A list of jobs waiting to be run, taken off in order by whatever runs them, such as an event loop phase or a pool of worker threads.
- call stack — The region of memory where a running program keeps one frame for each function call that has started but not yet returned.
Taught in
- Stacks And Queues: Last In Or First In — Algorithms & Data Structures for Working Engineers
- Breadth-First Search And Shortest Paths By Hops — Algorithms & Data Structures for Working Engineers
- Decoupling: SQS, SNS, EventBridge And Step Functions — AWS Certified Solutions Architect – Associate (SAA-C03) Exam Prep
- Ingest And Transform: Streams, Lakes And Partitions — AWS Certified Solutions Architect – Associate (SAA-C03) Exam Prep
- Event Loop Lifecycle: The Six Phases & libuv uv_run — Node.js Internals & Backend Services