Give any two characteristics of stacks.
A stack is like a stack of books
The Characteristics of Stacks are:
- It is a data structure which follows LIFO (Last-in-First-Out)
- The insertion and deletion happens at the same end i.e. from the top of the stack
- Stack is implemented through Array or Linked list .
- Stack is used in many algorithms like Tower of Hanoi, tree traversals.
- If the allocated space for stack is full , and any attempt to add more elements will lead to stack Overflow . The opposite , any attempt to extract elements on an empty stack leads to Stack Underflow .