A stack is a simple data structure for storing data. In stack, the order in which the data arrives is important. A pile of books is a good example of stack.
A stack is an ordered list in which insertion and deletion are done at one end, where end is called top. The last element inserted is the first one to be deleted. Hence, it is called Last in First Out (LIFO) or First in Last Out (FILO) list
In computer science, a stack is a particular kind of abstract data type or collection in which the principal (or only) operations on the collection are the addition of an entity to the collection, known as push and removal of an entity, known as pop. Often a peek or top operation is also implemented, returning the value ofthe top element without removing it.
- void push(int data) : Insert data onto stack.
- int pop() : Removes and returned last inserted element from the stack
- int top() or peek() : Returns the last inserted elements without removing it.
- int size() : Returns the number of elements stored in stack.
- boolean isStackFull() : Check whether stack is full or not.
- boolean isEmpty() : Check whether stack is empty or not.