1. Increasing the table size and reinserting all keys when the load factor is high is called:
- Hash collision
- Rehashing
- Chaining
- Probing
Answer: B) Rehashing
Explanation: It keeps operations near O(1). Lesson 3.5 · Data Structures & Algorithms
MCQs / Computer Science / NSCT: Data Structures & Algorithms
150 multiple-choice questions on NSCT: Data Structures & Algorithms from Computer Science, each with the correct answer and, where available, a teacher's explanation. Read through them to revise the chapter, then practise the same questions one by one to test yourself.
Answer: B) Rehashing
Explanation: It keeps operations near O(1). Lesson 3.5 · Data Structures & Algorithms
Answer: D) A B C +
Explanation: Multiplication has higher precedence. Lesson 3.2 · Data Structures & Algorithms
Answer: C) Post-order
Explanation: Post-order: left, right, root. Lesson 3.3 · Data Structures & Algorithms
Answer: B) Floyd-Warshall
Explanation: It uses dynamic programming in O(V³). Lesson 3.4 · Data Structures & Algorithms
Answer: D) [3, 2, 6, 4, 8]
Explanation: One pass swaps adjacent out-of-order pairs and moves the largest element to the end. Lesson 3.6 · Data Structures & Algorithms
Answer: C) Queue
Explanation: Nodes are processed in the order they were discovered. Lesson 3.2 · Data Structures & Algorithms
Answer: A) 10, 30, 20, 50, 60, 40
Explanation: Post-order visits left, right, then root – the first key inserted (root) comes last. Lesson 3.3 · Data Structures & Algorithms
Answer: B) Call stack
Explanation: Each call pushes a frame; returning pops it. Lesson 3.2 · Data Structures & Algorithms
Answer: A) 3
Explanation: Final table: [None, 28, 19, 20, None, 5, 15, None, None]. Lesson 3.5 · Data Structures & Algorithms
Answer: A) At both ends
Explanation: Deque = double-ended queue. Lesson 3.2 · Data Structures & Algorithms
Answer: A) dict and HashMap
Explanation: They give average O(1) lookup by key. Lesson 3.5 · Data Structures & Algorithms
Answer: C) 2
Explanation: The longest root-to-leaf path has 2 edges. Lesson 3.3 · Data Structures & Algorithms
Answer: A) Dynamic programming
Explanation: Greedy fails for 0/1 knapsack; DP gives the optimum. Lesson 3.6 · Data Structures & Algorithms
Answer: A) O(1)
Explanation: Only the head pointer changes. Lesson 3.2 · Data Structures & Algorithms
Answer: A) Topological sort
Explanation: It orders tasks respecting dependencies. Lesson 3.4 · Data Structures & Algorithms
Answer: A) Greedy algorithms
Explanation: They choose the best local option at each step. Lesson 3.6 · Data Structures & Algorithms
Answer: B) O(k)
Explanation: You must follow k links from the head. Lesson 3.2 · Data Structures & Algorithms
Answer: C) 3
Explanation: Queue after all operations (front→rear): ['3', '9', '1']. Lesson 3.2 · Data Structures & Algorithms
Answer: D) O(n log n)
Explanation: It always splits evenly and merges in linear time. Lesson 3.6 · Data Structures & Algorithms
Answer: C) O(log n)
Explanation: log n grows slower than any power of n. Lesson 3.1 · Data Structures & Algorithms
Answer: B) 40
Explanation: Queue after all operations (front→rear): ['40', '50']. Lesson 3.2 · Data Structures & Algorithms
Answer: B) y
Explanation: Queue after all operations (front→rear): ['y', 'z', 'w']. Lesson 3.2 · Data Structures & Algorithms
Answer: C) Negative edge weights
Explanation: Its greedy choice assumes edges cannot reduce a finalised distance. Lesson 3.4 · Data Structures & Algorithms
Answer: A) 1
Explanation: The root of a min-heap is always the smallest element. Lesson 3.3 · Data Structures & Algorithms
Answer: A) 40, 20, 10, 30, 60, 50
Explanation: Pre-order visits root, then left subtree, then right subtree. Lesson 3.3 · Data Structures & Algorithms
Page 1 of 6 Next
Practise NSCT: Data Structures & Algorithms MCQs