Stacks, Queues, and Abstract Data Types¶
- Abstract data types are sets of theoretical rules that revolve around some built-in data structure.
- Arrays with restrictions related to order.1
Stacks¶
- Data can only be added (push), removed (pop), and read (peek) from the top of the stack (i.e. end of the array)
- Stacks are last in first out (LIFO), whereas queues are first in first out (FIFO).
Queues¶
- Data can be added to the end (push/enqueue). It can be read and removed from the beginning (peek and dequeued)
- Queues are great for handling asynchronous processes.
-
A Common-Sense Guide to Data Structures and Algorithms in Python. Pragmatic bookshelf, 2023. ↩