# Recent questions tagged stack

1
Consider the following sequence of operations on an empty stack.$\textsf{push}(54);\textsf{push}(52);\textsf{pop}();\textsf{push}(55);\textsf{push}(62);\textsf{s}=\textsf{pop}();$ ... $\textsf{s+q}$ is ___________.
1 vote
2
Which of the following is the correct order of evaluation for the below expression? $z=x+y^*z/4\%2-1$ $^*/\%+-=$ $=^*/\%+-$ $/^*\%-+=$ $^*\% /-+=$
1 vote
3
What data structures is used for depth first traversal of a graph? Queue Stack List None of the above
4
In the ________ traversal we process all of a vertex's descendants before we move to an adjacent vertex. Depth First Breadth First Width First Depth Limited
1 vote
5
Assume that the operators $+,-,\times$ are left associative and $\wedge$ is right associative. The order of precedence(from highest to lowest) is $\wedge,\times, +,-$. The postfix expression corresponding to the infix expression $a+b\times c-d\wedge e\wedge f$ is $abc\times+def\wedge\wedge-$ $abc\times+de\wedge f\wedge-$ $ab+c\times d-e\wedge f\wedge$ $-+a\times bc\wedge\wedge def$
1 vote
6
The seven elements $A, B, C, D, E,F$ and $G$ are pushed onto a stack in reverse order, i.e., starting from $G$. The stack is popped five times and each element is inserted into a queue. Two elements are deleted from the queue and pushed back onto the stack. Now, one element is popped from the stack. The popped item is ___________. $A$ $B$ $F$ $G$
7
A stack is implemented with an array of $'A[0...N-1]'$ and a variable $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 ... initialize an empty stack with capacity $N$ for the above implementation $pos \leftarrow -1$ $pos\leftarrow 0$ $pos\leftarrow 1$ $pos\leftarrow N-1$
8
Show how to implement a stack using two queues. Analyze the running time of the stack operations.
1 vote
9
Explain how to implement two stacks in one array $A[1...n]$ in such a way that neither stack overflows unless the total number of elements in both stacks together is $n$.The $PUSH$ and $POP$ operations should run in $O(1)$ time.
1 vote
10
STACK-EMPTY(S) 1 if S.top == 0 2 return TRUE 3 else return FALSE PUSH(S , x) 1 S.top = S.top + 1 2 S[S.top] = x POP(S) 1 if STACK-EMPTY(S) 2 error “underflow” 3 else S.top = S.top – 1 4 return S[S.top + 1] illustrate the result of each operation in the sequence $PUSH(S,4), PUSH(S,1),PUSH(S,3),POP(S),PUSH(S,8),POP(S)$ on an initially empty stack $S$ stored in array $S[1...6]$
1 vote
11
A stack based CPU executes the instruction. Memory location $500$ contain $0X 88$ and memory location $700$ contain $0X37$. The stack pointer is at $0X003F$ The instruction are as follows: $I_{1}:PUSH$ $500$ $I_{2}:PUSH$. $700$ $I_{3}:ADD$ $I_{4}:POP$ ... $0X88$ after execution of instruction. $C)$ Memory location $600$ contain $0XBF$ after execution of instruction. $D)$ Both $a)$ and $c)$
12
There is given a infix expression: ${\color{Red} {1}}$ $A+B\times C/\left ( \left ( D+E \right )+F\times G \right )$ While converting infix expression to postfix expression number of symbols in the stack at indicated ${\color{Red} {point-1}}$ infix expression (assume stack is initially empty) ______________ they told $5$, but is it correct? Can anyone give some explanation??
1 vote
13
Is it TRUE or FALSE? Stack allocation can allocate and deallocate dynamic variables and can manage runtime storage
14
Generate code for the following three-address statements assuming stack allocation where register SP points to the top of the stack x = 1 x=a x = a + 1 x = a+b The two statements x = b * c y = a + x
1 vote
15
Runtime stack doesnot contain (A) Local variables (B) Static Variables (C) Parameter Passed (D) Return Address
16
infix ,postfix ,prefix expression evalution stack use as operator or operand?
1 vote
17
How many enqueue and dequeue operations are required to perform a pop operation if Q1 contains n element initially?
1 vote
18
5. Assume I have a stack s, a queue q, and a binary search tree t. Initially all of them are empty. Indicate the state of the data structures at line number 7 and at the end. What is the maximum height each of the data structures had during the execution? 1 i $\rightarrow$ 0 2 while i <= ... $\rightarrow$ 0 8 while i <= 9 do 9 t.insert(s.pop()) 10 t.insert(q.get()) 11 i $\rightarrow$ i + 1 12 end
19
Consider the following postfix expression with single digit operands : $6 \; 2 \: 3 \: ^* \: / \: 4 \: 2 \: ^* \; + \: 6 \: 8 \: ^* \: -$ The top two elements of the stack after the second $^*$ is evaluated, are : $8,2$ $8,1$ $6,2$ $6,3$
1 vote
20
true/false ? ) if stack is implemented as a array,all operation push ,pop ,is emptystack(),delete stack() can be performed in constant time. )if stack is implemented as a linked list ,all operation ,is emptystack(),delete stack() can be performed in constant time.
21
Ginmans Stack are a kind of special data structure in which if there are odd number of elements then the middle most element is popped out and printed on the screen. In case of even number of elements the recently popped out element is again pushed back either on the top or bottom of the stack randomly. Assume ... i, ii ii, iii iii, iv ii, iv
1 vote
22
What is the maximum number of activation records inserted into stack while converting following infix expression to postfix expression is Infix expression: 7+5*3^2/(9-2^2) + 6*4 ??
1 vote
23
If two stack is growing two opposite end of array. Then which logic works and how?
1 vote