Stack Data Structure: Practice Problems and Interview Questions
Published in
2 min readDec 26, 2018
--
A stack is a linear Last-In-Last-Out (LIFO) data structure which means that the last element added to the stack will be the first one to be removed. Therefore, once a new element is added to the stack, all elements that were added after it has to be removed before the new element can be removed.
In this post, we have listed out commonly asked interview questions that use stack data structure:
- Stack implementation using an array — C, C++, Java, Python
- Stack Implementation using a Linked List
- Implement a stack using the queue data structure
- Implement a queue using the stack data structure
- Design a stack that returns the minimum element in constant time
- Design a stack that returns a minimum element without using an auxiliary stack
- Implement two stacks in a single array
- Recursive solution to sort a stack
- Reverse a stack using recursion
- Reverse a string using a stack data structure
- Check if an expression is balanced or not
- Find duplicate parenthesis in an expression
- Evaluate a postfix expression
- Decode a given sequence to construct a minimum number without repeated digits
- Merging Overlapping Intervals
- Convert an infix expression into a postfix expression
- Find the next greater element for every element in a circular array
- Find the next greater element for every array element
- Find the previous smaller element for each array element
- Reverse an array in C++
- Longest Increasing Subsequence Problem
- Find all elements in an array that are greater than all elements to their right
- Iterative Implementation of Quicksort
- Find all binary strings that can be formed from a wildcard pattern
- Find the length of the longest balanced parenthesis in a string
- Reverse text without reversing individual words
- Reverse a string without using recursion
- Inorder Tree Traversal
- Preorder Tree Traversal
- Postorder Tree Traversal
- Check if two binary trees are identical or not
- Find ancestors of a given node in a binary tree
- Iteratively print the leaf to root path for every leaf node in a binary tree
- Find preorder traversal of a binary tree from its inorder and postorder sequence
- Construction of an expression tree
- Print complete Binary Search Tree (BST) in increasing order
- Depth First Search (DFS)
- Check whether the leaf traversal of given binary trees is the same or not
- Reverse level order traversal of a binary tree
- Invert Binary Tree
- Invert alternate levels of a perfect binary tree
- Depth-First Search (DFS) vs Breadth-First Search (BFS)
Thanks for reading.