Font size
WorksheetsDS-UNIT-2-Stack Queue
Total questions: 50
Worksheet time: 50mins
In a stack, if a user tries to remove an element from an empty stack it is called _________
Underflow
Empty collection
Overflow
Garbage Collection
Assume that the operators +, -, × are left associative and ^ is right associative. The order of precedence (from highest to lowest) is ^, x , +, -. The postfix expression corresponding to the infix expression a + b × c - d ^ e ^ f is
abc × + def ^ ^ -
abc × + de ^ f ^ -
ab + c × d - e ^ f ^
+ a × bc ^ ^ def
The result evaluating the postfix expression 10 5 + 60 6 / * 8 - is
284
213
142
71
If the elements "A", "B", "C" and "D" are placed in a queue and are deleted one at a time, in what order will they be removed?
ABCD
DCBA
DCAB
ABDC
A normal queue, if implemented using an array of size MAX_SIZE, gets full when?
Rear = MAX_SIZE - 1
Front = (rear + 1)mod MAX_SIZE
Front = rear + 1
Rear = front
How many stacks are needed to implement a queue. Consider the situation where no other data structure like arrays, linked list is available to you.
1
2
3
4
Which of the following is NOT a common operation in a queue data structure?
Enqueue
Dequeue
Peek
Shuffle
How many stacks are needed to implement a queue. Consider the situation where no other data structure like arrays, linked list is available to you.
1
2
3
4
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
Full: (REAR+1) mod n == FRONT, empty: REAR == FRONT
Full: (REAR+1) mod n == FRONT, empty: (FRONT+1) mod n == REAR
Full: REAR == FRONT, empty: (REAR+1) mod n == FRONT
Full: (FRONT+1) mod n == REAR, empty: REAR == FRONT
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
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
E
Consider the following operations performed on a stack of size 5 : Push (a); Pop() ; Push(b); Push(c); Pop(); Push(d); Pop();Pop(); Push (e) Which of the following statements is correct?
Underflow occurs
Stack operations are performed smoothly
Overflow occurs
None of the above
If elements are inserted in the order -10,-2,-3,4,-1,6 in a queue, then to delete value -3 how many dequeue operations are required?
(a)
A queue of characters currently contained A, B, C, D.
What would be the contents of queue after the following operation : DELETE, ADD W, ADD X, DELETE, ADD Y.
A,B,C,W,Y
A,B,C,D,W
C,D,W,X,Y
W,Y,X,C,D
If REAR, FRONT are the queue variables, then identify correct statement while inserting a value
FRONT=1
REAR=REAR+1
REAR=REAR-1
FRONT=FRONT-1
In a circular queue, when the rear pointer reaches the end of the array, it should:
stop inserting
move to the front
reset to zero
increase the size of the queue
Which of the following operations is not allowed in a queue?
Random Access
Traversal
Deletion
Insertion
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.
0
7
9
10
Suppose you have the following series of queue operations.
q = Queue();
q.enqueue(1);
q.enqueue(10);
q.enqueue(100);
q.dequeue();
q.dequeue();
What items are returned as output by dequeue operation?
10010
101
110
10010
One difference between a queue and a stack is:
Queues require linked lists, but stacks do not.
Stacks require linked lists, but queues do not.
Queues use two ends of the structure; stacks use only one.
Stacks use two ends of the structure, queues use only one.
Suppose you have the following series of queue operations.
q = Queue();
q.enqueue('hello');
q.enqueue('god');
q.enqueue(3);
q.dequeue();
What items are left on the queue?
'hello', 'god'
'god', 3
'hello', 3
'hello', 'god', 3
In a circular queue, how do you increment the rear end of the queue?
rear = rear + 1
(rear + 1) % queueSize
(rear % queueSize) + 1
rear = rear - 1
In linked list implementation of a queue, the important condition for a queue to be empty is?
FRONT is null
REAR is null
LINK is empty
None of the mentioned
Let the following circular queue can accommodate maximum six elements with the following data
front = 2 rear = 4
queue = _______; L, M, N, ___, ___
What will happen after ADD O operation takes place?
front = 2 rear = 5
queue = ______; L, M, N, O, ___
front = 3 rear = 5
queue = L, M, N, O, ___
front = 3 rear = 4
queue = ______; L, M, N, O, ___
front = 2 rear = 4
queue = L, M, N, O, ___
The essential condition which is checked before insertion in a linked queue is?
Underflow
Overflow
Front value
Rear value
What is the reason for using a "circular queue" instead of a regular one?
running time of enqueue() is improved
reuse empty spaces
you can traverse all the elements more efficiently
none of the above
The postfix form of the expression (A+ B)*(C*D- E)*F / G is?
AB + CDE * - * F *G /
AB+ CD*E - FG /**
AB + CD* E - F **G /
AB + CD* E - *F *G /
The prefix form of A-B/ (C * (D * E)) is?
-/*ACB*DE
-ABCD**DE
-A/B*C*DE
-A/BC**DE
Which of the following is based on the principle of Last In First Out?
Stack
Queue
Both
None of These
Which of the following data structures is used in recursion?
Stack
Queue
Both
None of these
Which of the following is the correct value of TOP if stack is empty?
0
Max-1
-1
None of these
Which of the following is the correct value of TOP if stack is full?
0
Max-1
-1
None of these
Which of the following conditions are met if queue is empty?
Front = -1 and Rear = -1
Rear = Max - 1
Rear = Front
None of these
Which of the following conditions are met if a queue is full?
Front = -1 and Rear = -1
Rear = Max - 1
Rear = Front
None of these
Which of the following conditions are met if a queue has only one element?
Front = -1 and Rear = -1
Rear = Max - 1
Rear = Front
None of these
The problem faced in Linear Queue is handled by implementing which of the following?
Circular Queue
Stack
Doubly ended queue
None of these
The underflow function, in a queue is handled returns a True in which of the following cases?
Front = -1 and rear = -1
Rear = Front
Rear = Max - 1
None of these
The underflow function, in a Stack returns a True in which of the following cases?
Top = -1
Top = Max - 1
Both
None of these
The overflow function, in a Stack returns a True in which of the following cases?
Top = -1
Top = Max - 1
Both
None of these
The overflow function, in a Queue returns a True in which of the following cases?
Front = -1 and rear = -1
Rear = Front
Rear = Max - 1
None of these
Which of the following is used in spooling?
Stack
Queue
Both
None of these
In a circular queue, how do you increment the rear end of the queue?
rear++
(rear+1) % Number of Item
(rear % Number of Item)+1
rear–
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
7
9
10
0
If the numbers 5, 10, 3, 42 are enqueued onto a queue in that order, what does dequeue return?
5
10
3
42
The essential condition which is checked before insertion in a linked queue is?
Underflow
Overflow
Front value
Rear value
A queue of characters currently contained A,B,C,D What would be the contents of queue after the following operationDELETE, ADD W, ADD X, DELETE, ADD Y.
A,B,C,W,Y
A,B,C,D,W
C,D,W,X,Y
W,Y,X,C,D
What will the stack contain after the following actions?
Push(1);
Push(2);
Push(3);
Push(4);
Pop();
Pop();
Push(5);
1, 2, 3
1, 2, 3, 5
1, 2, 3, 4, 5
1, 2, 5
Convert the infix exression
(A + B) * (C + D)
to Postfix.
A B C * + D +
A B + C D + *
A B * C D * +
A B + C + D +
Act of adding values into a stack is called
Popping
Polling
Pushing
None
Consider the following operation performed on a stack of size 5.
Push(1);
Pop();
Push(2);
Push(3);
Pop();
Push(4);
Pop();
Pop();
Push(5);
After the completion of all operation, the no of element present on stack are
1
3
2
4
