Stacks
Applications of Stacks
Stacks can be used in many different ways such a history in browsers or text editors.
Implementation of Stacks
A stack can either be implemented using an array or a linked list.
Commonly stacks have two variables. One being the top of the stack and the other being the stack itself.
Operations on a stack
Several operations can be used on a stack to manage it. These include:
- push(item) - Adding a new item to the stack.
- pop() - Remove the top most item and then return the removed item.
- peek() - Return the top most item without removing it.
- isEmpty() - Check if the stack is empty.
- size() - Return the size of the stack.
- isFull() - Check if the stack is full.