Stacks and Queues · Data Structures · GATE CSE
Start PracticeMarks 1
GATE CSE 2024 Set 1
Consider the operator precedence and associativity rules for the integer arithmetic operators given in the table below.
table { width: 100%; border-c...
GATE CSE 2021 Set 1
Consider the following sequence of operations on an empty stack.
push(54); push(52); pop(); push(55); push(62); s = pop();
Consider the following se...
GATE CSE 2016 Set 1
A queue is implemented using an array such that ENQUEUE and DEQUEUE operations are performed efficiently. Which one of the following statements is COR...
GATE CSE 2015 Set 3
The result evaluating the postfix expression $$10\,\,5\, + 60$$ $$\,\,6/\, * \,8\, - $$ is
GATE CSE 2005
A function f defined on stacks of integers satisfies the following properties.
f(∅) = 0 and f (push (S, i)) = max (f(S), 0) + i for all stacks S and ...
GATE CSE 2004
The best data structure to check whether an arithmetic expression has balanced parentheses is a
GATE CSE 1997
Which of the following is essential for converting an infix expression to the postfix form efficiently?
GATE CSE 1996
Consider the following statements:
(i) First-in-first out types of computations are efficiently supported by STACKS.
(ii) Implementing LISTS on link...
Marks 2
GATE CSE 2024 Set 2
Consider the following expression: $x[i] = (p + r) * -s[i] + \frac{u}{w}$. The following sequence shows the list of triples representing the given exp...
GATE CSE 2024 Set 2
Let S1 and S2 be two stacks. S1 has capacity of 4 elements. S2 has capacity of 2 elements. S1 already has 4 elements: 100, 200, 300, and 400, whereas ...
GATE CSE 2023
Consider a sequence a of elements $$a_0=1,a_1=5,a_2=7,a_3=8,a_4=9$$, and $$a_5=2$$. The following operations are performed on a stack S and a queue Q,...
GATE CSE 2022
Consider the queues Q1 containing four elements and Q2 containing none (shown as the Initial State in the figure). The only operations allowed on thes...
GATE CSE 2014 Set 2
Suppose a stack implementation supports an instruction REVERSE, which reverses the order of elements on the stack, in addition to the PUSH and POP ins...
GATE CSE 2012
Suppose a circular queue of capacity (n – 1) elements is implemented with an array of n elements. Assume that the insertion and deletion operations ar...
GATE CSE 2007
Suppose you are given an implementation of a queue of integers. The operations that can be performed on the queue are:
i. isEmpty (Q) — returns true ...
GATE CSE 2007
The following postfix expression with single digit operands is evaluated using a stack:
8 2 3 ^ / 2 3 * + 5 1 * -
Note that ^ is the exponentiation ...
GATE CSE 2007
Consider the following C program:
#include
#define EOF -1
void push (int); /* push the argument on the stack */
int pop (void); /* pop t...
GATE CSE 2006
The following function computes the value of mCn correctly for all legal values m and n (m≥1,n≥0 and m>n)
int func(int m, int n)
{
if (E) ...
GATE CSE 2006
An implementation of a queue Q, using two stacks S1 and S2, is given below:
void insert(Q, X){
push(S1, X);
}
void delete(Q){
if(stack - empty(S1)...
GATE CSE 2004
Assume that the operators +, -, ×, are left associative and ^ is right associative. The order of precedence (from highest to lowest) is ^, ×, +, -. Th...
GATE CSE 2004
A program attempts to generate as many permutation as possible of the string “abcd” by pushing the character a,b,c,d in the same order onto a stack, b...
GATE CSE 2003
Let S be a stack of size n >= 1. Starting with the empty stack, suppose we push the first n natural numbers in sequence, and then perform n pop ope...
GATE CSE 1998
Compute the post fix equivalent of the following expression.
3 * log(x+1) - a/2
GATE CSE 1998
What value would the following function return for the input x = 95?
function fun (x:integer):integer;
Begin
If x > 100 then fun : x –...
GATE CSE 1997
A priority queue Q is used to implement a stack that stores characters. PUSH (C) is implemented INSERT (Q, C, K) where K is an appropriate integer key...
GATE CSE 1995
The postfix expression for the infix expression
A + B * (C + D) / F + D * E is:
GATE CSE 1994
Which of the following permutations can be obtained in the output (in the same order) using a stack assuming that the input is the sequence 1, 2, 3, 4...
GATE CSE 1991
The following sequence of operations is performed on stack:
PUSH (10),PUSH (20),POP,PUSH (10),PUSH (20),POP,POP,POP,PUSH (20),POP
The sequence of th...