Summary
In this chapter, you learned about the stack data structure. We implemented our own algorithm that represents a stack, and you learned how to add and remove elements from it using the push
and pop
methods.
We compared different syntaxes that can be used to create the Stack class, and presented the pros and cons of each one. We also covered how to solve one of the most famous problems in Computer Science using stacks.
In the next chapter, you will learn about queues, which are very similar to stacks, but use a principle different than LIFO.