WorksheetsQUIZ-STACK_QUEUE_Jan'24
Total questions: 25
Worksheet time: 22mins
In which algorithm takes less time or space is called
Best case
Worst case
Average case
None of the above
A FIFO structure implemented as a ring where the front and rear pointers can wrap around the end of the start of the array.
Linear Queue
Circular Queue
Priority Queue
What is the disadvantage of array data structure?
Elements of an array can be accessed in constant time
Elements are stored in contiguous memory location
The amount of memory to be allocated should be known beforehand
Multiple other data structures can be implemented using Array
How can we describe an array in the best possible way?
The Array shows a hierarchical structure.
Arrays are immutable (Not Modifiable)
Container that stores the elements of similar types
The Array is not a data structure
____________data structures are those whose sizes and structures associated memory locations are fixed at compile time.
linear
homogeneous
static
dynamic
People have used the word ________ to mean computer information that is transmitted or stored.
Beta
Data
Database
None of above
Consider the usual algorithm for determining whether a sequence of parentheses is balanced.
Suppose that you run the algorithm on a sequence that contains 2 left parentheses and 3 right parentheses (in some order).
The maximum number of parentheses that appear on the stack AT ANY ONE TIME during the computation?
1
2
3
4 or more
User perform following operations on stack of size 5 then -
push(1);
pop();
push(2);
push(3);
pop();
push(2);
pop();
pop();
push(4);
pop();
pop();
push(5);
Overflow Occurs
Stack Operations will be performed Smoothly
Underflow Occurs
None of these
To evaluate an expression without any embedded function calls:
One stack is enough
Two stacks are needed
As many stacks as the height of the expression tree are needed
A Turing machine is needed in the general case
What will be the postfix form of the above expression -
(A+B)∗(C∗D-E)∗F/G
None of these
A B + C D ∗ E − F G ∗ / ∗
A B + C D E ∗ − F G / ∗ ∗
A B + C D ∗ E − F G / ∗ ∗
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
Which of the following is not an inherent application of stack?
Implementation of recursion
Evaluation of a postfix expression
Job scheduling
Reverse a string
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, ___
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
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
One difference between a queue and a stack is:
Queues require dynamic memory, but stacks do not
Stacks require dynamic memory, 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.
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
Where would pointers be pointing if...
- Eli leaves the Queue.
- Hanna joins the Queue.
- Adam joins the Queue.
- Jason leaves the Queue.
front = 0 rear = 5
front = 1 rear = 4
front = 2 rear = 4
front = 0 rear = 4
front = 2 rear = 5
What would happen if...
deQueue()
enQueue(Hanna)
enQueue(Steve)
enQueue(Jack)
front = 1 rear = 0
*and Steve would be unable to be added to position 0.
front = 1 rear = 5
*and Jack would be unable to be added to position 0
front = 0 rear = 5
front = 0 rear = 4
front = 1 rear = 4
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
Which is the application of a queue?
CPU allocation
Sharing printer
Graph traversal
All
