August 2017
Intermediate to advanced
222 pages
5h 3m
English
A stack stores data in the same way that arrays do—it’s simply a list of elements. The one catch is that stacks have the following three constraints:
You can think of a stack as an actual stack of dishes: you can’t look at the face of any dish other than the one at the top. Similarly, you can’t add any dish except to the top of the stack, nor can you remove any dish besides the one at the top. (At least, you shouldn’t.) In fact, most computer science literature refers to the end of the stack as its top, and the beginning of the stack as its bottom.
While these restrictions seem—well—restrictive, ...