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 ___________.
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 ___________.
94 | |
83 | |
79 | |
86 |
Question 1 Explanation:
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.
Which of the following will initialize an empty stack with capacity N for the above implementation?
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?
\text { pos } \leftarrow-1 | |
\text { pos } \leftarrow 0 | |
\text { pos } \leftarrow 1 | |
\text { pos } \leftarrow N-1 |
Question 2 Explanation:
Question 3 |
Convert the pre-fix expression to in-fix -^{*}+A B C^{*}-D E+F G
(A-B)^{*} C+\left(D^{*} E\right)-(F+G) | |
(A+B)^{*} C-(D-E)^{*}(F-G) | |
(A+B-C)^{*}(D-E)^{*}(F+G) | |
(((A+B)*C)-((D-E)*(F+G))) |
Question 3 Explanation:
Originally all Options are wrong. We have modified one option.
Click here for detail solution by gateoverflow
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+(b-c))^{\star}((d-e) /(f+g-h))
{ }^{\star}+a-b c /-d e-+f g h | |
{ }^{\star}+a-b c -/d e-+f g h | |
{ }^{\star}+a-b c /-ed-+f g h | |
{ }^{*}+\mathrm{ab}-\mathrm{c} /-\mathrm{de}-+\mathrm{fgh} |
Question 4 Explanation:
Question 5 |
The best data structure to check whether an arithmetic expression has balanced parenthesis is a:
Queue | |
Stack | |
Tree | |
List |
Question 5 Explanation:
Question 6 |
The following postfix expression with single digit operands is evaluated using a stack:
8 \ 2 \ 3 \ \;\hat{}\; / \ 2 \ 3 * + 5 \ 1 * -
Note that \hat{}\; is the exponentiation operator. The top two elements of the stack after the first * is evaluated are
8 \ 2 \ 3 \ \;\hat{}\; / \ 2 \ 3 * + 5 \ 1 * -
Note that \hat{}\; is the exponentiation operator. The top two elements of the stack after the first * is evaluated are
6,1 | |
5,7 | |
3,2 | |
1,5 |
Question 6 Explanation:
Question 7 |
If the sequence of operations - push (1), push (2), pop, push (1), push (2), pop, pop, pop, push (2), pop are performed on a stack, the sequence of popped out values
2,2,1,1,2 | |
2,2,1,2,2 | |
2,1,2,2,1 | |
2,1,2,2,2 |
Question 7 Explanation:
Question 8 |
The result evaluating the postfix expression 10 5 + 60 6 / * 8 - is
284 | |
213 | |
142 | |
71 |
Question 8 Explanation:
Question 9 |
The five items: A, B, C, D, and E are pushed in a stack, one after other starting from A. The stack is popped four items and each element is inserted in a queue. The two elements are deleted from the queue and pushed back on the stack. Now one item is popped from the stack. The popped item is
A | |
B | |
C | |
D |
Question 9 Explanation:
Question 10 |
Suppose a stack implementation supports an instruction REVERSE, which reverses the order
of elements on the stack, in addition to the PUSH and POP instructions. Which one of the
following statements is TRUE with respect to this modified stack?
A queue cannot be implemented using this stack. | |
A queue can be implemented where ENQUEUE takes a single instruction and
DEQUEUE takes a sequence of two instructions. | |
A queue can be implemented where ENQUEUE takes a sequence of three instructions
and DEQUEUE takes a single instruction | |
A queue can be implemented where both ENQUEUE and DEQUEUE take a single
instruction each. |
Question 10 Explanation:
There are 10 questions to complete.