Stacks: The LIFO Structure
A Stack is a linear data structure that follows the Last-In, First-Out (LIFO) principle. Think of a pile of plates: you can only add or remove from the top.
Primary Operations:
• Push: Adds an element to the top of the stack.
• Pop: Removes and returns the top element.
• Peek/Top: Returns the top element without removing it.
• isEmpty: A boolean check to see if the stack contains data, essential for avoiding underflow errors.
• isFull: Checks if a fixed-size stack (like one implemented with an array) has reached its capacity to prevent overflow errors.