Stacks
A stack is a list where the last element to be placed in the list is always the first element to be removed.
Stack Operations
Push: This is where you add an element to the top of the stack.
Pop: This is where you remove an element from the top of the stack.
Peek: This is where you look at the element on the top of the stack.
What Are Stacks Good For
Stacks are good for remembering the past, and giving a preference to the most recent events first. They are often used to implement undo operations. This is because you have to undo things in the reverse order that they were done. Stacks are also useful for recursion. This is because during a task you can delegate a new operation, but you want to come back and finish your current task. An example would be that you are writing a letter, but your pen runs out of ink. Getting a new pen gets pushed to the top of the stack, but once done you remove getting a pen from the stack to go back to writing the letter.