Member-only story
Stack vs. Queue — How To, When To, and Why To Use Them
Everything you need to know about using the stack and queue data structures
Linear data structures are essential to software engineering and provide the foundations required to build the many features we use every day — think news feeds and notifications systems. When given the task to build these features, many engineers simply turn to arrays without considering two very important data structures: stacks and queues.
This article is a deep dive into the stack and queue data structures, their use cases, trade-offs and implementations. By the end of this article, you’ll have a clear understanding of stacks and queues to be able to use them in your own engineering tasks.
Table of Contents
- Why Should You Care About Stacks and Queues?
- What is a Stack?
- What is a Queue?
- Stack vs Queue — Use Cases
a) Stack use cases
b) Queue use cases - How to Implement a Stack and Queue
a) How to build a stack
b) How to build a queue - Stack vs Queue Summary