AlgoFrames

Overflow handling

Warm-up · Multiple choice · about 2 min

An array stack has 3 slots and already holds 4, 7 and 2, so top = 2. A caller runs push(8). What should a well-written push do?

Example 1

Input:

push(8)

Output:

overflow

Learn the idea first: Stacks: push, pop, peek; array and linked implementations, a visual lesson.

More Stacks: push, pop, peek; array and linked implementations problems