Original Practice Questions 3 versions
1. Which of the following best describes the difference between a
static array and a dynamic array?
A. Static arrays can store any data type; dynamic arrays cannot
B. Static arrays have fixed capacity; dynamic arrays can resize automatically
C. Dynamic arrays use linked nodes; static arrays use contiguous memory
D. Static arrays support O(1) insertion at the front; dynamic arrays do not
B. Static arrays have fixed capacity; dynamic arrays can resize
automatically
A static array's size is determined at creation and cannot change. A dynamic
array automatically allocates additional capacity (often doubling) when the
array becomes full, providing flexible storage while retaining indexed access .
2. A dynamic array with capacity 4 is full with elements [10, 20, 30, 40].
After appending 50, what is the most common new capacity?
A. 5
B. 6
C. 8
D. 10
C. 8
Dynamic arrays commonly double their capacity when resizing. Doubling
from 4 yields a new capacity of 8, which keeps the amortized cost of appends
at O(1) .
3. In a singly-linked list, which operation is O(n) in the worst case?
,A. Inserting a node at the head
B. Removing the head node
C. Searching for a value
D. Checking if the list is empty
C. Searching for a value
Searching a singly-linked list requires traversing from the head node,
potentially visiting all n nodes. Inserting or removing at the head is O(1)
because only pointer updates are required .
4. Which of the following is a correct statement about a doubly-linked
list's memory usage compared to a singly-linked list?
A. A doubly-linked list uses less memory per node
B. A doubly-linked list uses more memory per node because of the extra
previous pointer
C. Both use identical memory per node
D. Doubly-linked lists do not store data
B. A doubly-linked list uses more memory per node because of the
extra previous pointer
Each node in a doubly-linked list stores an additional reference to the
previous node, increasing per-node memory overhead compared to a singly-
linked list .
5. A circular linked list is most useful when:
A. Random access by index is required
B. Operations need to cycle repeatedly through the list
C. Data must be stored in sorted order
D. Memory usage must be minimized
B. Operations need to cycle repeatedly through the list
,In a circular linked list, the tail node references the head, allowing continuous
traversal without resetting to the head. This is useful for round-robin
scheduling and circular buffers .
6. Which operation on a stack removes the most recently added item?
A. Enqueue
B. Dequeue
C. Push
D. Pop
D. Pop
The pop operation removes and returns the item at the top of the stack,
which is the most recently pushed item (LIFO behavior). Push adds an item;
enqueue and dequeue are queue operations .
7. A queue processes elements in which order?
A. Last-In, First-Out
B. First-In, First-Out
C. Priority order
D. Random order
B. First-In, First-Out
A queue is a FIFO structure: items are inserted at the rear and removed from
the front, so the earliest inserted item is removed first .
8. What is the primary advantage of implementing a queue with a
circular array over a linear array?
A. Faster element access
B. Reuse of vacated positions at the front
C. Automatic sorting of elements
D. Reduced memory per element
B. Reuse of vacated positions at the front
, A circular array wraps indices using modulo arithmetic, allowing the queue to
reuse positions freed by dequeued elements rather than shifting or wasting
space .
9. Which of the following best describes a deque?
A. A structure where insertion occurs only at the front
B. A structure where insertion and removal occur at both ends
C. A structure that stores only unique elements
D. A structure that maintains sorted order
B. A structure where insertion and removal occur at both ends
A deque (double-ended queue) supports insertion and removal at both the
front and the back, combining stack and queue capabilities .
10. In an array-based list, what is the worst-case time complexity of
inserting an element at index 0?
A. O(1)
B. O(log n)
C. O(n)
D. O(n^2)
C. O(n)
Inserting at index 0 requires shifting all existing n elements one position to
the right, resulting in O(n) time complexity .
11. What property must a binary search tree maintain for every node?
A. Both children must have equal keys
B. Left subtree keys are less than the node; right subtree keys are greater
C. The tree must be perfectly balanced
D. Every node must have two children
B. Left subtree keys are less than the node; right subtree keys are
greater