Stack


Question 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 sequence of operations on an empty queue.

enqueue(21); enqueue(24); dequeue(); enqueue(28); enqueue(32); q=dequeue();

The value of s+q is ___________.
A
94
B
83
C
79
D
86
GATE CSE 2021 SET-1   Data Structure
Question 2
A stack is implemented with an array of { }^{\prime} A[0 \ldots N-1]^{\prime} and a variable \text { 'pos'. } The push and pop operations are defined by the following code.
 push (x)
    A[pos] <- x
    pos <- pos -1
end push
pop()
    pos <- pos+1
    return A[pos]
end pop

Which of the following will initialize an empty stack with capacity N for the above implementation?
A
\text { pos } \leftarrow-1
B
\text { pos } \leftarrow 0
C
\text { pos } \leftarrow 1
D
\text { pos } \leftarrow N-1
ISRO CSE 2020   Data Structure


Question 3
Convert the pre-fix expression to in-fix -^{*}+A B C^{*}-D E+F G
A
(A-B)^{*} C+\left(D^{*} E\right)-(F+G)
B
(A+B)^{*} C-(D-E)^{*}(F-G)
C
(A+B-C)^{*}(D-E)^{*}(F+G)
D
(((A+B)*C)-((D-E)*(F+G)))
ISRO CSE 2020   Data Structure
Question 3 Explanation: 
Originally all Options are wrong. We have modified one option.
Click here for detail solution by gateoverflow
Question 4
Choose the equivalent prefix form of the following expression
(a+(b-c))^{\star}((d-e) /(f+g-h))
A
{ }^{\star}+a-b c /-d e-+f g h
B
{ }^{\star}+a-b c -/d e-+f g h
C
{ }^{\star}+a-b c /-ed-+f g h
D
{ }^{*}+\mathrm{ab}-\mathrm{c} /-\mathrm{de}-+\mathrm{fgh}
ISRO CSE 2017   Data Structure
Question 5
The best data structure to check whether an arithmetic expression has balanced parenthesis is a:
A
Queue
B
Stack
C
Tree
D
List
ISRO CSE 2017   Data Structure


There are 5 questions to complete.

Leave a Comment