A Stack is a Last In First Out (LIFO) data structure.
used to store data in a last in first out format, meaning that the last item added onto the stack is the first item that will be removed from it.
The basic operations supported by a stack are:
Push adds an element at the top of a stack.
Pop removes the topmost element of a stack
The peek() method returns the element on the top of the stack but does not remove it.
The empty() method returns true if the stack is empty, otherwise, it returns false.
Stacks follow these concepts:
First In Last Out (FILO) : the first item added in the stack will be the last item popped out of the stack.
Last In First Out (LIFO) : the last item added to the stack will be the first item popped out of the stack.
What is a Queue
Enqueue : this method adds an element to the end/rear of the queue
Dequeue : this method removes an element from the front of the queue
Front : Return the front object in the queue, but do not remove it; an error occurs if the queue is empty”
Rear : This is the rear/last Node of the queue.
Peek : This function returns the value of the topmost element available in the stack.
IsEmpty : If the stack is empty, then this function will return a true value or else it will return a false value.
Queues follow these concepts:
First In First Out (FIFO) the element inserted at first in the list, is the first element to be removed from the list.
Last In Last Out (LILO) method for handling data structures where the Last element is processed Last