Pages

Categories

Stack

Stack
Published on 10 March, 2014
The stack data structure is a last in first out (LIFO) type that has two core operations, push,
and pop. Only access to the top of the stack is available and there is no way to randomly
access/modify an element in the middle of the stack.
Definitions:
 Stack Origin – The starting memory location on the stack.
 Stack Bound – The last memory location on the stack.
 Head of Stack – The current element at the top of the stack.
 Stack Overflow – When a value is pushed onto the stack, exceeding the stack
bounds.
 Stack Underflow – When a pop operation is performed on an empty stack, and
attempts to read memory before the stack origin.
Operations:
 Create – Creates a stack.
 Push – Pushes a value onto the stack.
 Pop – Takes a value from the top of the stack.
 Peek – Look at the value at the top of the stack without removing it; effectively a pop
and push operation combined on the head.
 Empty – Check if the stack is empty.
Diagram:
Filed in Computer Science Revision | No replies