SOLID STATE PRESS
← Back to catalog
Stacks and Queues cover
Coming soon
Coming soon to Amazon
This title is in our publishing queue.
Browse available titles
Computer Science

Stacks and Queues

A High School & College Primer on Two Essential Data Structures

You have a data structures exam coming up, or your CS class just hit stacks and queues and the textbook lost you three pages in. This guide is the shortcut.

**TLDR: Stacks and Queues** covers everything a high school or early college student needs to understand, implement, and apply these two foundational data structures — in under 20 pages. You'll learn the difference between LIFO and FIFO, work through the full API for both structures, see array and linked-list implementations with real code, and understand why the naive array queue is slow and how a circular buffer fixes it. The guide also covers deques and priority queues, then closes with the canonical real-world problems — balanced parentheses, undo functionality, breadth-first search, the call stack, and task scheduling — so you can recognize a stack or queue problem the moment you see one.

This is an intro to data structures for college students and advanced high school learners who want clarity fast. No padding, no lengthy theory — just the concepts, the code, and the worked examples you need. It's also a solid resource if you're searching for a data structures study guide for high school CS or AP Computer Science Principles review.

If you want to walk into your next class or exam knowing exactly how these structures work and where they appear, pick this up and read it in one sitting.

What you'll learn
  • Explain the LIFO and FIFO access rules and when each is appropriate
  • Implement a stack and a queue using arrays and linked lists, and reason about their time complexity
  • Recognize stack and queue patterns in real problems like undo, expression evaluation, BFS, and scheduling
  • Use specialized variants — deques, circular queues, priority queues, and the call stack — with confidence
  • Solve standard interview-style problems involving stacks and queues
What's inside
  1. 1. What Stacks and Queues Actually Are
    Introduces both structures by analogy and contrasts LIFO with FIFO using everyday examples.
  2. 2. The Stack: Operations, Implementation, and Complexity
    Covers the full stack API, implements it with both an array and a linked list, and analyzes performance.
  3. 3. The Queue: Operations, Implementation, and the Circular Buffer Trick
    Builds the queue API, shows why a naive array implementation is slow, and fixes it with a circular buffer.
  4. 4. Variants You Should Know: Deques and Priority Queues
    Introduces double-ended queues and priority queues, what they add, and where they get used.
  5. 5. Where They Show Up: Real Problems and Algorithms
    Walks through canonical applications — balanced parentheses, expression evaluation, undo, BFS, the call stack, and scheduling.
Published by Solid State Press
Stacks and Queues cover
TLDR STUDY GUIDES

Stacks and Queues

A High School & College Primer on Two Essential Data Structures
Solid State Press

Who This Book Is For

If you're staring down a unit on data structures in your AP Computer Science class, working through an intro to data structures for college students course, or just trying to make sense of why your professor keeps drawing boxes and arrows on the board — this book is for you. It also works for self-taught programmers who want a clean, fast foundation before tackling bigger topics.

This is a focused algorithms and data structures primer for anyone who needs stacks and queues explained for beginners without the padding. It covers LIFO and FIFO data structures with a quick guide to operations, Big-O complexity, array and linked-list implementations, circular buffers, deques, and priority queues. Think of it as a data structures study guide for high school and early college — about 15 pages, no filler.

Read straight through to learn stacks and queues in your computer science class, work every example as you go, and finish with the problem set. These short computer science concept study book sections are designed to be read in one sitting.

Contents

  1. 1 What Stacks and Queues Actually Are
  2. 2 The Stack: Operations, Implementation, and Complexity
  3. 3 The Queue: Operations, Implementation, and the Circular Buffer Trick
  4. 4 Variants You Should Know: Deques and Priority Queues
  5. 5 Where They Show Up: Real Problems and Algorithms
Chapter 1

What Stacks and Queues Actually Are

Every program needs a way to store and retrieve data. A data structure is any organized arrangement that lets you store values and access them according to specific rules. Arrays, for example, let you reach any element instantly by index. Two of the most useful structures — stacks and queues — trade that random access for something narrower on purpose: they enforce a strict rule about which item you can touch next.

That constraint sounds like a limitation. It is actually a feature. When the order in which you process items is part of the problem, a structure that enforces an order keeps your logic clean and your code correct.

The Stack: Last In, First Out

Picture a stack of cafeteria trays. When a clean tray arrives, it goes on top. When you need a tray, you take one from the top. The tray that was added most recently is the first one removed. There is no reaching to the middle or the bottom.

This access rule has a name: LIFO, which stands for last in, first out. A stack is any data structure that follows LIFO. You interact with it through exactly two core operations:

  • Push: add an item to the top of the stack.
  • Pop: remove the item currently on top and return it.

A common student mistake is to think of a stack as just an array you can push and pop on. The difference is that an array lets you index any position; a stack only exposes the top. That restriction is what makes a stack useful — it guarantees the order of removal matches the reverse of the order of insertion.

Example. You push the values 1, 2, and 3 onto an empty stack, in that order. What order do they come off when you pop three times?

Solution. The last value pushed was 3, so it sits on top. Popping gives 3 first, then 2, then 1. The output order is 3, 2, 1 — the reverse of the insertion order.

Keep reading

You've read the first half of Chapter 1. The complete book covers 5 chapters in roughly fifteen pages — readable in one sitting.

Coming soon to Amazon