Stack : stack is a special type of data structure where element are inserted from one end and element are deleted from the same point
This positions from where element are deleted and element are inserted is called top of the stack. This approach the last element inserted in the first element to be deleted out and hence, is take is also called last in first out data structure .stack is also called LIFO.
Example:- a good example of stack " a garage that is only one car wide.to remove the first car in we have to take out all the other cars in after it."
Various good example that can be performed stack:-
(1) Push operation
(2)Pop operation
(3)Peek operation
(4) check if empty
(5) initialisation of the stack
Push operation:- inserting an element on the top of stack.
Example:- stack contents after inserting 4items 30,20,25,10 one after the other with a stack size 4.
Step 1: we find empty stack
Step2: first insert 30
Step3:than insert 20
Step3 insert 25
Step4:next insert 10
So size of stack =4
pOp operation:-deleting an element from the top of stack.
Peek operation:-looking at the first element of the stack.
Check if empty:- check if stack is empty.
Initialisation of the stack:-creat a new stack.