Open Book test
Q1.) What do you understand by stack data structure. Give some real life
examples of stack.
Stack is a linear data structure which follows Last In First Out (LIFO) principle i.e.,
element inserted last in stack will be the first one to be removed.
Insertion and deletion in the stack is performed at one end only which is called
top of the stack.
For e.g.) vertical piles of chairs, books arranged in book shelves
Q2.) What are the major operations related to stack?
Stack has two major operations:
i.) Push: It's an insertion operation where element in stack is added at the top of
the stack
ii.) Pop: It's a deletion operation where element is removed from the top of the
stack.
Q3.) Define overflow and underflow condition in stack?
Overflow condition: A stack becomes full if all of its memory is exhausted. If we try to add
an element in a stack which is already full then it becomes overflow condition.
Underflow condition: A stack is considered empty if it doesn't contain any
element. If we try to remove an element from empty stack then it becomes
underflow condition.