Computer Science
Stacks

A stack is a Last In First Out (LIFO) data structure. You push new items onto the top of the stack. You pop items from the top of the stack to remove them. A pointer indicates the top of the stack.

 

 

Stacks are used in calculations and translation from one computer language to another. They are also used to reverse items in a list or array.

When a recursive procedure is called, a stack of records is used to store the local variables for each procedure call as well as the return address (ie the exact line of the procedure to return to.

Overflow & Underflow

When a stack or queue is full, attempting to add a new element will create an overflow error. When the stack or queue is empty, attempting to remove an element creates an underflow error.