Data Structures

Stacks

Push, pop and other stack operations, why top starts at -1 and where stacks are used.

Why Is Top Set to -1 in a Stack?

Why the top index of an array-based stack starts at -1 instead of 0, how that value marks an empty stack, and how push and pop depend on that value.

3 min read

Related topics

More in data structures