Multiple-Choice Questions with Verified Answers &
Detailed Rationales (Rated A+) Latest Update
2026/2027
Section 1: Data Structures & Abstract Data Types
1. Which data structure is most appropriate for implementing an undo feature in
a text editor?
A) Queue
B) Stack
C) Priority Queue
D) Hash Table
Correct Answer: B) Stack
Rationale: Undo requires LIFO (Last In, First Out) behavior – the most recent
operation is undone first.
2. In a circular queue implemented with an array, the condition for a full queue
(using front and rear pointers) is:
A) front == rear
B) (rear + 1) % size == front
C) rear == size – 1
D) front == (rear + 1) % size
Correct Answer: B) (rear + 1) % size == front
Rationale: To distinguish between full and empty, one slot is left unused; full
occurs when the next rear position wraps to front.
3. What is the worst-case time complexity for searching an element in a balanced
binary search tree (BST) of n nodes?
A) O(1)
B) O(log n)
C) O(n)
D) O(n log n)
1
,Correct Answer: B) O(log n)
Rationale: In a balanced BST (e.g., AVL or Red-Black tree), height is O(log n), so
search takes O(log n) worst case.
4. Which data structure uses FIFO (First In, First Out) order?
A) Stack
B) Queue
C) Array
D) Linked List
Correct Answer: B) Queue
Rationale: A queue follows FIFO – the first element inserted is the first to be
removed.
5. A priority queue is typically implemented using which underlying data
structure?
A) Stack
B) Linked List
C) Heap
D) Hash Table
Correct Answer: C) Heap
Rationale: Heaps provide O(log n) insertion and O(log n) removal of the highest
(or lowest) priority element.
6. What is the primary disadvantage of a singly linked list compared to an array?
A) More memory per element
B) No random access
C) Slower insertion at head
D) Cannot store heterogeneous data
Correct Answer: B) No random access
Rationale: Singly linked lists require O(n) time to access the i-th element, whereas
arrays provide O(1) random access.
7. In a doubly linked list, deletion of a given node (with a pointer to that node)
takes:
A) O(1) time
B) O(log n) time
2
,C) O(n) time
D) O(n log n) time
Correct Answer: A) O(1) time
Rationale: With a pointer to the node, you can update its predecessor’s next
pointer and its successor’s prev pointer in constant time.
8. A hash table with separate chaining has a load factor α. The average time for an
unsuccessful search is:
A) O(1)
B) O(α)
C) O(log α)
D) O(n)
Correct Answer: B) O(α)
Rationale: Unsuccessful search examines the entire chain; average chain length is
α = n / table_size.
9. Which tree traversal visits the root first, then the left subtree, then the right
subtree?
A) Inorder
B) Preorder
C) Postorder
D) Level-order
Correct Answer: B) Preorder
Rationale: Preorder follows Root → Left → Right.
10. A complete binary tree with 7 nodes has how many leaf nodes?
A) 3
B) 4
C) 5
D) 6
Correct Answer: B) 4
Rationale: In a complete binary tree, leaves are at the last level; for 7 nodes,
levels 1,2,3; leaves = 4 (nodes 4,5,6,7 in array representation).
3
, Section 2: Algorithms & Complexity
11. What is the time complexity of binary search on a sorted array of size n?
A) O(1)
B) O(log n)
C) O(n)
D) O(n log n)
Correct Answer: B) O(log n)
Rationale: Each step halves the search space, leading to log₂(n) comparisons.
12. Which sorting algorithm has the best worst-case time complexity?
A) Bubble Sort
B) Quick Sort
C) Merge Sort
D) Insertion Sort
Correct Answer: C) Merge Sort
Rationale: Merge sort guarantees O(n log n) even in worst case; quicksort can
degrade to O(n²).
13. The worst-case time complexity of quicksort occurs when:
A) The pivot is the median element
B) The array is already sorted and the pivot is the first element
C) The array contains all equal elements
D) The array size is a power of two
Correct Answer: B) The array is already sorted and the pivot is the first element
Rationale: This produces the most unbalanced partitions (size 0 and n-1), leading
to O(n²).
14. Which of the following is NOT a stable sorting algorithm?
A) Merge Sort
B) Bubble Sort
C) Quick Sort (typical in-place implementation)
D) Insertion Sort
4