A beginners guide to using Queue and Stack data structures in your code.
When you start learning about data structures and algorithms, things can get complicated really fast. So this article is meant to slow things down and get you comfortable with two common data structures (Queues & Stacks) that are often used as the basic building blocks in more complex algorithm implementations.
You are already using these data structures in your code, you just don’t know it!
Alright so what is a queue? A more official definition reads something like this:
“A collection of elements that is maintained in sequence and can be modified by the addition of a new element at the back of the collection or the removal of an existing element at the front of the collection.”
Ultimately, a Queue is a first-in-first-out (FIFO) data structure. Here is a simple image that illustrates how this process looks: