02 StackQueueWithAnswers
02 StackQueueWithAnswers
1.
The postfix expression specified below, with single digit operands is evaluated using a stack. The top two
elements of the stack after the first * is evaluated will be (Note that ^ is the exponentiation operator):
823^/23*+51*-
A. 6, 1
B. 5, 7
C. 3, 2
D. 1, 5
Answer: A
2.
The data structure required to check whether an expression contains balanced parenthesis is?
A. Stack
B. Queue
C. Tree
D. Array
Answer: A
3.
The five items:A,B,C,D, and E are pushed in a stack, one after the other starting from A The stack is
popped four times and each element is inserted in a queue.Then 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. E
B. B
C. C
D. D
Answer: D
4.
A linear list of elements in which deletion can be done from one end (front) and insertion can take place
only at the other end (rear) is known as a ?
A. Queue
B. Stack
C. Tree
D. Linked list
Answer: A
5.
Which of the following statements is true:
i) First in First out types of computations are efficiently supported by STACKS.
ii) Implementing LISTS on linked lists is more efficient than implementing LISTS on an array for
almost all the basic LIST operations.
iii) Implementing QUEUES on a circular array is more efficient than implementing QUEUES on a
linear array with two indices.
iv) Last in First out type of computations are efficiently supported by QUEUES
1
Stack Queue
A. (ii) and (iii) are true
B. (i) and (ii) are true
C. (iii) and (iv) are true
D. (ii) and (iv) are true
Answer: A
6.
A priority queue Q is used to implement a stack S that stores characters. PUSH(C) is implemented as
INSERT(Q, C, K) where K is an appropriate integer key chosen by the implementation. POP is
implemented as DELETEMIN(Q). For a sequence of operations, the keys chosen will be in:
A. Non-increasing order
B. Non-decreasing order
C. strictly increasing order
D. strictly decreasing order
Answer: D
7.
Suppose a circular queue of capacity (n - 1) elements is implemented with an array of n elements.
Assume that the insertion and deletion operation are carried out using REAR and FRONT as array
index variables, respectively. Initially, REAR = FRONT = 0. The conditions to detect queue full and
queue empty are?
Answer: A
8.
In the array implementation of circular queue, which of the following operation take worst case linear
time?
A. Insertion
B. Deletion
C. To empty a queue
D. None
Answer: D
9.
A circular queue is implemented using an array of size 10. The array index starts with 0, front is 6, and
rear is 9. The insertion of next element takes place at the array index.?
A. 0
B. 7
C. 9
D. 10
Answer: A
2
Stack Queue
10.
The infix expression A+B/C*(D+E)-F when converted to postfix the result would evaluate to?
A. ABC/DE+*+F-
B. ABC/ED*+F-
C. AB+/CED*F-
D. ABC/D+*EF-
Answer: A
11.
What will be the result of postfix expression 7532^*922^-/+64*+?
A. 38
B. 41
C. 40
D. 35
Answer: C
12.
The data structure required for Breadth First Traversal on a graph is?
A. Stack
B. Array
C. Queue
D. Tree
Answer: c
13.
When it comes to Process scheduling in operating system the following Datastructure is preferred?
A.Stack
B.Queue
C.Array
D.All of above
Answer: B
14.
Which of the following is true about linked list implementation of queue?
A. In push operation, if new nodes are inserted at the beginning of linked list, then in pop operation,
nodes must be removed from end.
B. In push operation, if new nodes are inserted at the end, then in pop operation, nodes must be
removed from the beginning.
C. Both of the above
D. None of the above
Answer: C
3
Stack Queue
15.
The Infix expression (A+B^C)*D+E^5 when converted to prefix expression the result would evaluate to
A. +*+A^BCD^E5
B.*++A^BCD^E%
C.+*+A^BC^DE5
D.*+A+^BDC^E5
Answer: A