- LIFO - Last In First Out
The stack data structure is a sequential collection of elements that follows the principle of LIFO (last in first out).
Ex: Stack of Plates
-
push(element): Add an element to the top of Stack.
-
pop(): Remove the top element from Stack and return the pop'd value.
-
peek(): Get the value of the top element without removing it.
-
isEmpty(): Check if the stack is empty.
-
size(): Get the number of elements in Stack.
-
print(): Visualize the element in Stack.