Learning order

1. Array

Free

Start your learning journey by understanding the most fundamental data structure.

Show Index

2. Singly Linked List

Free

Learn in-depth the most fundamental data structure in a programmer's life

Show Index

3. Doubly Linked List

Premium

Learn about the extension of the singly linked list that powers stacks and queues

Show Index

4. Hash Table

Premium

Learn how applications deal with key value mappings efficiently

Show Index

5. Stack

Premium

The data structure behind recursion, memory management, and much more

Show Index

6. Queue

Premium

Learn about the data structure that powers CPU and disk scheduling algorithms

Show Index

7. Binary Tree

Premium

Learn all about the most critical data structure in computer science

Show Index

8. Binary Search Tree

Premium

Learn about the most critical search data structure in computer science

Show Index

9. Heap

Premium

Learn all how a tree can be used as a priority queue

Show Index

10. Graph

Premium

Learn about the most dynamic data structure in computer science

Show Index

What you will learn

Why FIFO ordering matters in music players, call centers, disk schedulers, and BFS traversal

The four queue properties (capacity, size, front, back) and bounded versus unbounded queues

How modular arithmetic wraps an array queue's back index to reuse dequeued slots

How a tail pointer turns linked list enqueue from an O(N) walk into an O(1) append

How to design a queue from two stacks with O(1) amortised operations

The trade-offs between array-backed and linked list queues across capacity, locality, and memory cost

Why this course

A queue looks like the easiest data structure to build until you try. Enqueue adds to the back, dequeue removes from the front, and both sketch in thirty seconds on a whiteboard. Then an interviewer asks you to implement one on a fixed-size array, and the obvious approach throws away every slot you ever dequeue from.

This course teaches queues by building them. You start with the four use cases that motivate FIFO ordering, then implement a circular array queue and a singly linked list queue from scratch, then walk three design problems where queues and stacks rebuild each other. You finish with five working queue and stack implementations of your own.

Requirements

The course assumes you can read code in any mainstream language and have a working sense of arrays and linked lists.

  • Comfort writing loops, conditionals, and classes in at least one language.
  • Familiarity with basic Big-O notation (O(N), O(1)).
  • A working sense of how arrays and singly linked lists behave, at the level of indexing and pointer chasing.

Overview

A queue is the data structure you reach for whenever the order things arrive in matters more than what they contain. Operating system schedulers, printer spoolers, message brokers like Kafka and RabbitMQ, and the BFS traversal that finds the shortest path in an unweighted graph all rely on the same first-in-first-out rule. Python's deque, Java's Queue, C++'s std::queue, and Go's buffered channels are the same idea dressed up in different syntax: two open ends, with insertion at the back and removal from the front. Once you understand why those two ends move independently, both the implementations and the design problems fall into place.

Representation of a queue

The course covers both halves of the topic: how the queue behaves abstractly, and how to build one in code from a fixed-size array, a singly linked list, and a pair of stacks.

Fundamentals

The course opens with why FIFO ordering deserves a data structure of its own. You see four concrete use cases (music players, call centers, disk schedulers, and printer queues) that all share the same shape: incoming work has to be served in the order it arrived. From there the four queue properties (capacity, size, front, back) and the five supported operations (enqueue, dequeue, front, back, size) are introduced together, so you can reason about complexity before any implementation appears.

The middle of the course is the array implementation. You see why a naive array-backed queue wastes the slots freed by dequeue, and how a circular queue reclaims them by wrapping the back index back to zero using (i + 1) % capacity. Every operation (enqueue, dequeue, front, back, empty, size) is built up one method at a time against the same shared state of arr, frontIndex, backIndex, currentSize, and capacity. By the time you finish this section you can explain why a full queue and an empty queue would otherwise look identical, and how currentSize resolves the ambiguity.

The fundamentals close with the linked list implementation. You see why keeping a tail pointer alongside the head turns enqueue from an O(N) end-of-list walk into an O(1) append, and how maintaining currentSize as a member variable does the same for the size query. By the end of fundamentals you have built two distinct queue implementations behind the same external interface, and you can argue both ways about which one to use in a given situation.

Problem solving

The final section is built around design problems. A design question hands you an empty class skeleton and asks you to implement the queue contract from scratch using a different underlying structure, the same kind of question that appears in nearly every Big Tech onsite that touches data structures.

The 5 queue and stack implementations you'll build
Circular array queue
An array-backed queue that wraps backIndex with modular arithmetic to reuse slots freed by dequeue, supporting all five queue operations in O(1) time. Design a Queue Using Circular Array.
Linked list queue
A singly linked list queue with head as the front and tail as the back, giving O(1) enqueue and dequeue and an unbounded capacity that grows with memory. Design a Queue Using Linked List.
Queue using two stacks
An input stack collects enqueues and an output stack serves dequeues, so the amortised cost across N operations is O(1) per call even though a single dequeue can be O(N). Design a Queue Using Stacks.
Stack using two queues
One queue holds the data and the second is used as a temporary buffer during push, giving O(N) push and O(1) pop, or the reverse depending on which operation you choose to make heavy. Design a Stack Using Queues.
Stack using one queue
A single queue plus a rotation step on every push gives a working stack with O(N) push and O(1) pop without needing a second queue at all. Design a Stack Using a Single Queue.

Every implementation is taught the same way. First you see the structure laid out, then each operation is built up one method at a time against shared state, then the edge cases (empty queue, full queue, single element) are handled explicitly rather than left as exercises. By the end you have written five distinct queue and stack implementations with your own hands, and you understand the trade-off behind each design choice.

How this course is different

Most queue material on the internet either reduces the topic to a one-line FIFO definition or treats the design questions as standalone LeetCode problems. This course handles each on its own terms.

Most DSA resources
This course
âś—Cover queues in a single page that lists enqueue and dequeue and moves on to BFS.
✓Starts with the four FIFO use cases (music, call centers, disk schedulers, printer queues) so the operations have a reason to exist.
âś—Skip the circular array trick, leaving you unable to explain why a non-cyclic queue wastes slots.
✓Teaches the cyclic array layout and the (i + 1) % capacity arithmetic that make an array-backed queue practical.
âś—Show the linked list implementation without explaining why the tail pointer matters.
✓Builds the linked list implementation around the tail pointer, with currentSize tracked in a member variable for O(1) size queries.
âś—Mention "design a queue from two stacks" as a LeetCode question without teaching the amortisation argument.
✓Walks three design problems (queue from stacks, stack from queues, stack from a single queue) as first-class material, not bonus content.
âś—Never have you implement a queue yourself, so you cannot build one when an interviewer asks.
✓Finishes with five working implementations rather than a memorised interface.

Who this course is for

The course suits anyone who wants to understand queues from the implementation side rather than guess at the design questions.

  • New programmers who have used a built-in queue or list but never written enqueue and dequeue themselves.
  • Self-taught and bootcamp graduates who can describe FIFO but freeze when asked to implement a queue on a fixed-size array.
  • Working developers who reach for blocking queues, message queues, or task queues at work without knowing how they are built underneath.
  • Engineers preparing for FAANG and Big Tech interviews where "design a queue using two stacks" and BFS questions appear in nearly every onsite.
  • Returning engineers who learned queues years ago and want a refresher grounded in concrete code rather than abstract definitions.
  • Anyone heading into graph and BFS topics who wants queues solid before adding traversal logic on top.

Continue your DSA journey

Queues sit alongside arrays and linked lists as one of the foundational data structures, and they reappear inside graph and design topics later. After this course, the natural next steps depend on what you want to deepen.

  • Array: Arrays back the most common queue implementation. The circular queue you build here leans on the same index arithmetic the array course covers in its memory model section. Working through arrays alongside or just before queues makes the modular wrap obvious instead of magical.
  • Singly linked list: The other queue implementation. Once you have seen how head holds the front and tail holds the back, every linked list pattern (fast and slow, reversal, sliding window) feels like the same pointer-chasing skill applied differently.
  • Doubly linked list: The natural extension of a queue is a deque, where insertion and removal both work at either end. A doubly linked list is the structure that supports it cleanly, and the course also covers reversal and reorder patterns that build on the linked list mental model.
  • Stack: Queues and stacks are duals, FIFO versus LIFO, and the design problems in this course (queue from stacks, stack from queues) make the relationship concrete. The stack course teaches the patterns (previous closest, next closest, sequence validation, linear evaluation) that complete the picture.
  • Heap: A heap is the structure you reach for when a queue needs to serve items by priority rather than by arrival order. After understanding the regular FIFO queue, the priority queue's behaviour and its O(log N) insertion become a clean contrast.
  • Graph: BFS uses a queue to traverse a graph level by level, and the shortest-path-on-an-unweighted-graph pattern is mostly a queue-driven loop. Doing queues first makes the BFS implementation in the graph course feel like a small step rather than a whole new idea.

Frequently asked questions

Code examples use Python for readability, but every concept (FIFO ordering, circular indexing, head and tail pointers, amortisation across two stacks) is language-agnostic. The course explicitly shows how Python's deque, Java's Queue, and C++'s std::queue map onto the same internal machinery.
Yes. The course starts from why FIFO ordering matters in everyday systems (music players, call centers, disk schedulers) and builds the queue from there. If you can write a for loop in any language and read Big-O notation like O(N), you have everything you need. A working sense of arrays and singly linked lists helps but is not required.
There are around 21 lessons across four sections (introduction, array implementation, linked list implementation, and design) plus five design problems. Most learners finish the lessons in 6 to 10 hours and need another 6 to 10 hours to work through the design problems, depending on prior experience.
Queue material shows up in two places in real onsites: explicit design questions ("design a queue from two stacks", "design a stack from queues") and graph problems where BFS leans on a queue. Both are covered directly in this course. You will recognise the structure on first read of the problem.
LeetCode shows you a design problem and a sample solution with no context for why one approach is preferred. This course builds two real queue implementations first, then walks the design questions as natural extensions of what you already know. You leave understanding the amortisation argument behind "queue from two stacks" rather than memorising the trick.
In a naive array-backed queue, every dequeue advances frontIndex forward and leaves the old cell unused. Once backIndex reaches the last cell of the array, the queue refuses to enqueue even though empty slots are sitting unused at the start. A circular queue fixes this by wrapping backIndex (and frontIndex) back to zero with (i + 1) % capacity, so dequeued slots get reused instead of leaking. Without the wrap, the queue's effective capacity shrinks by one for every dequeue ever performed.
An array-based queue uses one contiguous allocation, gives you tight memory locality and good cache behaviour, and supports all five operations in O(1). The catch is that capacity is bounded at construction time, so you have to size it correctly upfront. A linked list queue allocates one node per item, so it grows until memory runs out, but each enqueue pays an allocation cost and the per-item memory overhead is several times the data itself. Use the array implementation when the maximum size is known and performance matters. Use the linked list implementation when the queue's size cannot be predicted.
Yes. Once you finish all lessons and the five design problems, codeintuition issues a shareable certificate you can post to LinkedIn or attach to a job application.