Linear data structure following LIFO (Last In, First Out) principle.
What is Stack? A stack is a non-primitive linear data structure. it is an ordered list in which the addition of a new data item and deletion of the already existing data item is done from only one...
Problem Statement: Design a data structure to implement ‘N’ stacks using a single array of size ‘S’. It should support the following operations: push(X, M): Pushes an element X into the Mth...
Problem Statement: You need to try implementing 2 stacks in a single array. Examples Input : Array size = 10 Operations: push1(1), push1(2), push2(11), pop1(), push1(3), push2(12) Output : pop1() �...
Problem Statement: Given a postfix expression Containing only operators [+, - , *, / ] and numbers. Postfix expression is given the form of a vector of strings. Each element is either operator or o...
Problem Statement: Implement a Last-In-First-Out (LIFO) stack using a singly linked list. The implemented stack should support the following operations: push, pop, top, and isEmpty. Implement the L...
Problem Statement: Evaluation of prefix expression step by step. Examples Example 1: Input: * 5 4 Output: 20 Example 2: Input: + 5 * 4 6 Output: 29 Disclaimer : It's highly recommend trying to solv...
Before understanding the infix, prefix, and postfix let’s understand why this came into practice and what are its uses. What is the use of these notations? Infix notation is easy to read for huma...
Problem Statement: Given an infix expression, Your task is to convert the given infix expression to a prefix expression. Examples Example 1: Input: x + y * z / w + u Output: ++x/*yzwu Explanation:...
Problem Statement: Given an infix expression, Your task is to convert the given infix expression to a postfix expression. Examples Example 1: Input: a + b * (c^d - e) ^ (f + g * h) - i Output: abcd...
What is a stack? Stack is a linear data structure in which elements are stored in a certain order. It follows the LIFO or FILO approach which is Last In First Out or First In Last Out respectively....