The FIFO Principle

Introduction

A queue is one of the simplest data structures to describe and one of the easiest to misuse if you do not take its ordering rule seriously. That rule is FIFO: First-In, First-Out. The first element placed into the queue is the first element taken out, and no operation is allowed to violate that order. Insertion happens at one end (the rear, via enqueue) and removal happens at the other (the front, via dequeue), which is what keeps the ordering honest.

FIFO matters in this course for two reasons. First, it is a defining constraint, not a convenience: the queue is interesting precisely because it refuses to let you reach into the middle. That restriction is what makes it predictable and what makes it the right tool for scheduling, buffering, print spooling, breadth-first traversal, and any situation where arrival order should determine service order. Second, FIFO becomes much clearer when you set it beside LIFO, the stack's ordering rule, where insertion and removal share a single end.

While watching, pay attention to three things: where elements enter and where they leave, how the front and rear positions move as operations occur, and how the stack's single point of access produces reversed output compared to the queue's preserved order. If you can predict the exact sequence of outputs for a given sequence of operations on both structures, you understand the principle.

Video 1: Lec-46: Introduction to Queue Data structure with real life example | Data Structure #queue

Gate Smashers · 9:05 · 227,838 views · 3y ago · captions — Watch on YouTube

About this video

This lecture introduces the queue as an abstract data type and grounds it in a real-life analogy, which is the standard way of making the FIFO rule intuitive. Expect coverage of the basic structure of a queue, the roles of the front and rear ends, and how insertion and removal operations follow First-In, First-Out ordering. It serves as the foundational overview for the module.

Why this video

Gate Smashers produces exam-oriented computer science lectures with a reputation for clear, step-by-step explanations, and this video directly addresses what FIFO means and how insertion and removal work under it — the core of this topic.

Video 2: Lec-30: Introduction to Stack | PUSH and POP operations | Data Structure

Gate Smashers · 6:46 · 325,606 views · 3y ago · captions — Watch on YouTube

About this video

This lecture introduces the stack and its two fundamental operations, PUSH and POP, explaining how both occur at a single end of the structure. It is likely to walk through how elements accumulate and are removed in reverse order of insertion, which is the LIFO principle. Although the subject is the stack, it provides the contrast you need to understand the queue.

Why this video

Understanding FIFO is sharpest by comparison, and this companion lecture from the same instructor supplies the LIFO side of the contrast with consistent terminology and presentation style, supporting the FIFO-versus-LIFO subtopic directly.

How These Videos Support the Learning Outcomes

Together these two videos cover the conceptual half of the module. The queue introduction supports MO1 by defining FIFO and showing how it governs enqueue and dequeue at opposite ends of the structure, and it begins the work of MO5 by connecting the ordering rule to realistic scenarios where arrival order should determine service order. The stack lecture supports MO4 by supplying the LIFO contrast — a single point of access producing reversed output — so you can articulate precisely how the two structures differ in ordering and access. Note that implementation details and complexity trade-offs (MO2 and MO3) are addressed elsewhere in the module; your goal here is to be fluent in the ordering principle before you write any code.

About These Videos

These videos were chosen from YouTube on October 2, 2026. Each has captions; the player turns them on. Videos on YouTube can be changed or removed — if one no longer plays, tell your instructor. If a player does not appear, use its Watch on YouTube link.