A stack permutation is a permutation of objects in the given input queue which is done by transferring elements from input queue to the output queue with the he
Given a Stack, keep track of the maximum value in it. The maximum value may be the top element of the stack, but once a new element is pushed or an element is p
Given a number , write a program to reverse this number using stack. Examples: Input : 365 Output : 563 Input : 6899 Output : 9986 Recommended: Please try your
Suppose we have two Strings :- Pattern and Text pattern: consisting of unique characters text: consisting of any length We need to find the number of patterns t
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 stack st
We all know about Stacks also known as Last-In-First-Out(LIFO) structures. Stack primarily has two main operation namely push and pop, where push inserts an ele
Given a stack of integers, write a function pairWiseConsecutive() that checks whether numbers in the stack are pairwise consecutive or not. The pairs can be inc
Given a stack with push(), pop(), empty() operations, delete middle of it without using any additional data structure. Input : Stack[] = [1, 2, 3, 4, 5] Output
Given a stack, sort it using recursion. Use of any loop constructs like while, for..etc is not allowed. We can only use the following ADT functions on Stack S:
Given a stack of integers, sort it in ascending order using another temporary stack. Examples: Input : [34, 3, 31, 98, 92, 23] Output : [3, 23, 31, 34, 92, 98]
Given an array of N distinct elements where elements are between 1 and N both inclusive, check if it is stack-sortable or not. An array A[] is said to be stack
Reverse a Stack without using recursion and extra space. Even the functional Stack is not allowed. Examples: Input : 1->2->3->4 Output : 4->3->2->1 Input : 6->5
Java Collection framework provides a Stack class which models and implements Stack data structure. The class is based on the basic principle of last-in-first-ou
Stacks are a type of container adaptors with LIFO(Last In First Out) type of working, where a new element is added at one end and (top) an element is removed fr
Design a stack with following operations. a) push(Stack s, x): Adds an item x to stack s b) pop(Stack s): Removes the top item from stack s c) merge(Stack s1, S
How to Implement stack using a priority queue(using min heap)?. Asked In: Microsoft, Adobe. Recommended: Please try your approach on {IDE} first, before moving
Deque also known as double eneded queue, as name suggests is a special kind of queue in which insertions and deletions can be done at the last as well as at the
We are given queue data structure, the task is to implement stack using only given queue data structure. We have discussed a solution that uses two queues. In t
.NET is a software framework which is designed and developed by Microsoft. The first version of .Net framework was 1.0 which came in the year 2002. In easy word
A Stack is used to represent a last-in, first out collection of objects. It is used when you need last-in, first-out access to items. It is of both generic and
The computers which use Stack-based CPU Organization are based on a data structure called stack. The stack is a list of data words. It uses Last In First Out (L
1. Subroutine – A set of Instructions which are used repeatedly in a program can be referred to as Subroutine. Only one copy of this Instruction is stored in
Stack is an abstract data type with a bounded(predefined) capacity. It is a simple data structure that allows adding and removing elements in a particular order