A stack is an abstract data type that serves as a collection of elements, with two principal operations: push, which adds an element to the collection, and pop, which removes the most recently added element that was not yet removed. The order in which elements come off a stack gives rise to its alternative name, LIFO (for last in, first out). Additionally, a peek operation may give access to the top without modifying the stack.
Considered as a linear data structure, the push and pop operations occur only at one end of the structure, referred to as the top of the stack. This makes it possible to implement a stack as a singly linked list and a pointer to the top element.
A stack may be implemented to have a bounded capacity. If the stack is full and does not contain enough space to accept an entity to be pushed, the stack is then considered to be in an overflow state. The pop operation removes an item from the top of the stack.
Below is the list of commonly asked interview questions that uses stack data structure-
- Stack Implementation
- Stack Implementation using Linked List
- Check if given expression is balanced expression or not
- Find duplicate parenthesis in an expression
- Evaluate given postfix expression
- Decode the given sequence to construct minimum number without repeated digits
- Inorder Tree Traversal | Iterative & Recursive
- Preorder Tree Traversal | Iterative & Recursive
- Postorder Tree Traversal | Iterative & Recursive
- Find ancestors of given node in a Binary Tree
- Check if two given binary trees are identical or not | Iterative & Recursive
- Reverse given text without reversing the individual words
- Find all binary strings that can be formed from given wildcard pattern
- Iterative Implementation of Quicksort
- Depth First Search (DFS) | Iterative & Recursive Implementation
- Invert given Binary Tree | Recursive and Iterative solution
Thank you for being with us. 🙂