Step 1: Push operation.
The push operation is used to insert an element onto the top of the stack. This operation increases the size of the stack by one and places the new element on top.
Step 2: Pop operation.
The pop operation is used to remove the top element from the stack. This operation decreases the size of the stack by one and removes the most recently added element.
Step 3: Peek or Top operation.
The peek operation is used to access the top element of the stack without removing it. This allows users to check the value at the top of the stack without modifying the stack.
Step 4: isEmpty operation.
The isEmpty operation checks whether the stack is empty or not. It returns true if the stack contains no elements, otherwise false.
Step 5: Size operation.
The size operation returns the number of elements present in the stack. It helps to keep track of the stack's current size.