# Category Archives: Stack

Given a Queue data structure that supports standard operations like enqueue() and dequeue(). The task is to implement a Stack data structure using only instancesâ€¦ Read More
Given preorder traversal of a binary search tree, construct the BST.For example, if the given traversal is {10, 5, 1, 7, 40, 50}, then theâ€¦ Read More
In a party of N people, only one person is known to everyone. Such a person may be present at the party, if yes, (s)heâ€¦ Read More
Create a data structure twoStacks that represent two stacks. Implementation of twoStacks should use only one array, i.e., both stacks should use the same arrayâ€¦ Read More
Question: Design a Data Structure SpecialStack that supports all the stack operations like push(), pop(), isEmpty(), isFull() and an additional operation getMin() which should returnâ€¦ Read More
Spaghetti stack A spaghetti stack is an N-ary tree data structure in which child nodes have pointers to the parent nodes (but not vice-versa) Spaghettiâ€¦ Read More
Given an array, print the Next Greater Element (NGE) for every element.  The Next greater Element for an element x is the first greater elementâ€¦ Read More
Write a program to reverse a stack using recursion, without using any loop. Example:  Input: elements present in stack from top to bottom 1 2â€¦ Read More
Given an expression string exp, write a program to examine whether the pairs and the orders of “{“, “}”, “(“, “)”, “[“, “]” are correctâ€¦ Read More
Using Stack is the obvious way to traverse tree without recursion. Below is an algorithm for traversing binary tree using stack. See this forâ€¦ Read More
The problem is opposite of this post. We are given a stack data structure with push and pop operations, the task is to implement aâ€¦ Read More
Given a Binary Tree, the task is to print the Level order traversal of the Binary Tree in spiral form i.e, alternate order. Example: Input:Output:â€¦ Read More