Posts

Showing posts from December, 2020

ROLE OF STACK AND QUEUES IN PROBLEM SOLVING

Image
Introduction to stacks and queues A stack is an ordered collection of items where the addition of new items and the removal of existing items always takes place at the same end. This end is commonly referred to as the “Top”, and the opposite end is known as the “Base”. A queue is an ordered of items where the addition of new items happens at one end , called the “rear”, and the removal of existing items occurs at the other end , commonly called the “front”. As an element enters the queue it starts at the rear and makes its way toward the front , waiting until that time when it is the next element to be removed . Stack is a linear data structure which follows a particular order in which the operations are performed. The order may be LIFO(Last In First Out) or FILO(First In Last Out). Mainly the following three basic operations are performed in the stack: Push: Adds an item in the stack. If the stack is full, then it is said to be an Overflow condition. Pop: Removes an ite...