LOGBOOK

HELP

Quiz Entry - updated: 2026.09.29

What are the performance and the limitations of the array-based stack?

Every operation is $O(1)$ and $n$ elements need $O(n)$ memory; but the maximum size is fixed when the stack is created, and pushing onto a full stack throws an implementation-specific exception.

Performance:

  • Each operation changes one index and reads or writes at most one array cell, so push, pop, top, size and isEmpty all run in $O(1)$.
  • Memory is $O(n)$ for the array (more precisely, for its fixed capacity, whether used or not).

Limitations:

  • Fixed capacity. The array length is chosen at construction and never changes. The stack cannot grow beyond it.
  • Full-stack exception. push on a full stack throws an IllegalStateException.

That exception deserves a closer look. It has nothing to do with the Stack ADT, which describes an unbounded collection: push always succeeds. The limit comes purely from the chosen implementation. A stack built on a linked list, or on an array that doubles when full, does not have it. This is the ADT/implementation split in action: the same operations, but each implementation brings its own limits.

From Quiz: ADS / Linear Data Structures: Lists, Stacks, Queues, Deques, Iterators | Updated: Sep 29, 2026