Role of Stacks and Queues in Problem Solving
Stacks A Stack is a linear data structure which follows the LIFO or Last-In-First-Out principle. It basically means that the last element which will be inserted in the stack will be the very first one to leave the stack. Stack contains only a single pointer i.e. the top pointer which points to the very top most element of the following stack. Whenever an element is added in the stack, it is added from the top of the stack, and that element can also be deleted only from the very top of the stack. We can also say that a stack can be defined as a bucket in which the processes of insertion and deletion can only be done from the one end which is commonly known as top of the stack. Standard Stack Operations Some very common operations which are implemented on the stack are: push(): Whenever we add an element in the stack then the operation is known as push operation. If the stack is already full and we try to add an element then the stack overflow occurs. pop(): When we delete an element f...