Unit 3: Stacks and Queues - Practice Quiz
1 Which principle determines the order in which elements are removed from a stack?
2 Which everyday object best illustrates the behavior of a stack?
3 In a linked-list representation of a stack, which pointer usually identifies the element available for removal?
4
What does the top variable usually store in an array-based stack?
5 In which direction are elements commonly visited when traversing a stack?
6 What does the push operation do?
7 What condition occurs when an element is pushed onto a full array-based stack?
8 What does the pop operation do?
9 What condition occurs when pop is attempted on an empty stack?
10
In the infix expression $A + B$, where is the operator placed?
11
Which expression is the prefix form of $A + B$?
A B +
A B + +
+ A B
A + B
12
What is the value of the postfix expression 5 2 +?
13
Which postfix expression is equivalent to the infix expression A * B?
A * B
A B *
A B * A B
* A B
14 Which two indices are commonly maintained in an array-based queue?
front and rear
current, previous, and next for every array element
top and bottom
left and right
15 In a linked-list queue, where is a new node normally inserted?
16 In what order are elements normally visited during queue traversal?
17 What is the standard name for inserting an element into a queue?
18 From which end is an element removed in a standard queue?
19 What mainly determines the removal order in a priority queue?
20 What is a defining feature of a deque?
21
A sequence of operations on an empty stack is push(12), push(7), pop(), and push(9). Which element is now at the top?
22
In a singly linked-list stack whose top is stored at the head, which operation sequence correctly pushes a new node N?
top.next = N, then top = N
top = N.next, then N = top
N.next = top, then top = N
N.next = null, then top.next = N
23
An array stack has capacity 8 and uses top = -1 when empty. If top = 6, what happens when two push operations are attempted?
24
An array stack contains [4, 8, 15, 16] from bottom to top. Which output is produced by a standard traversal from top downward?
25
For an array-based stack using top = -1 initially, which pseudocode correctly performs a push after checking for overflow?
S[top] = item; top = top + 1
S[top + 1] = item; top = top - 1
top = top - 1; S[top] = item
top = top + 1; S[top] = item
26
An array stack contains [3, 6, 9] with top = 2. After one valid pop, what are the returned value and new value of top?
top = 1
top = 2
top = 1
top = 0
27
What is the value of the infix expression $8 + 3 \times 4 - 6 \div 2$ under standard precedence rules?
28
Which prefix expression represents the infix expression $(A-B) \times (C+D)$?
- * A B + C D
* A - B + C D
+ - A B * C D
* - A B + C D
29
What is the result of evaluating the postfix expression 5 2 3 * + 4 -?
30
What is the postfix form of the infix expression A + B * (C - D)?
A B + C D - *
A B C * D - +
A B * C D - +
A B C D - * +
31
A linear array queue of capacity 6 has front = 2 and rear = 5. Although indices 0 and 1 are unused, why can a normal insertion still fail?
32
A linked queue maintains front and rear pointers. When inserting into a nonempty queue, which pointer changes to reference the new node?
front
rear
33
A circular queue of capacity 7 has front = 5 and rear = 1. Which index order visits all occupied positions from front to rear?
34
In a circular queue of capacity $n$, which update moves rear to the next position during insertion?
rear = (rear + 1) % n
rear = (front + 1) % n
rear = rear + front
rear = (rear - 1) % n
35 A linked queue contains exactly one node. Which pointer state should result after deleting that node?
front and rear become null
rear becomes null
front becomes null
36 A min-priority queue contains items with priorities 7, 2, 5, and 3, where a smaller number means higher priority. Which priority is removed first?
37
Starting with an empty deque, perform insertRear(4), insertFront(7), insertRear(9), and deleteFront(). What remains from front to rear?
38
While evaluating the prefix expression - + 9 4 * 2 3, what final value is obtained?
39
During infix-to-postfix conversion, the operator stack currently has + below *. When a - is read, which operators are popped before - is pushed?
*
* and +
+
40
A stable priority queue receives P, Q, and R in that order, all with the same priority. In what order should they be removed?
41
A stack has capacity and uses top = -1 initially. The operations are: push(A), push(B), push(C), pop(), push(D), push(E), push(F). What is the final stack from bottom to top and the value of top?
top = 3
top = 4
top = 4
top = 4
42
In a singly linked-list implementation of a stack, the top pointer refers to the first node. Which operation sequence correctly performs pop() while preserving time complexity?
top, then delete the second node
top, move top to top.next, then delete the stored node
43
A stack is stored in an array with top = 4, containing from bottom to top. A traversal must display elements from top to bottom without modifying the stack. Which output is correct?
44 A dynamically resizing array stack doubles its capacity whenever a push is attempted on a full stack. Starting with capacity , what is the amortized time complexity of pushes, and what is the total number of element moves caused by resizing?
45
An array stack uses one-based indexing and stores the number of elements in top. Which condition must be checked before pop() to prevent underflow?
top == capacity - 1
top == 1
top == 0
top == capacity
46 Assuming exponentiation has higher precedence than multiplication and is right-associative, which value does the infix expression evaluate to?
47 Which prefix expression is equivalent to the infix expression ?
48
Evaluate the postfix expression 8 2 / 3 - 4 2 ^ + using integer operands and exact division.
49 Using standard precedence and right-associative exponentiation, what is the postfix form of ?
A B C D ^ * + E F G ^ ^ -
A B C ^ D * + E F ^ G ^ -
A B C D ^ * E F G ^ ^ + -
A B + C D ^ * E F G ^ ^ -
50
A circular queue has capacity , with front = 4 and rear = 1. Here, front points to the first element and rear points to the next insertion position. How many elements are currently stored?
51
In a linked-list queue with both front and rear pointers, what must occur when deleting the only node in the queue?
front to the deleted node's successor
front to NULL
rear to NULL
front and rear to NULL
52
A circular queue of capacity has front = 5, rear = 2, where rear is the next insertion position. Which index sequence represents a complete traversal from front to rear without including the unused rear position?
53
A circular queue uses capacity , front as the first element, and rear as the next insertion position. Initially front = rear = 0. After inserting four elements and deleting two elements, which state is correct?
front = 1, rear = 3, with two elements stored
front = 2, rear = 3, with one element stored
front = 2, rear = 4, with two elements stored
front = 0, rear = 4, with four elements stored
54
A circular queue has capacity , front = 3, and rear = 1, with rear indicating the next insertion position. After one deletion, what are the new pointer values?
front = 3, rear = 0
front = 4, rear = 0
front = 4, rear = 1
front = 2, rear = 1
55 A priority queue removes the item with the smallest priority value. Items are inserted in this order: , , , . If equal priorities are served FIFO, what is the deletion order?
56
A deque initially contains from front to rear. Apply insertFront(5), deleteRear(), insertRear(40), and deleteFront(). What is the final deque?
57 A stack receives the input sequence exactly once. Which output sequence cannot be produced using only push and pop operations?
58 When evaluating a postfix expression containing binary operators, which invariant must hold immediately before applying an operator?
59 What is the prefix form of the infix expression ?
60 A binary min-heap priority queue contains the array . After deleting the minimum element and restoring heap order, which array can represent the resulting heap?
Did this save you a night before the exam?
LPU Notes is free, and it stays free. Ads cover part of the server bill. The rest comes out of a student's own pocket: the domain, the storage, and keeping the site up through the weeks everyone needs it at once.
The payment button didn't load. An ad blocker or a filtered network is the usual reason. to try again.
Nothing here is ever locked, and nothing unlocks. Chip in only if it was worth it. What it pays for →