51. What is the maximum number of comparisons binary search needs to find an item in a sorted array of 5,000 elements?
- 13
- 26
- 10
- 2500
Answer: A) 13
Explanation: ⌊log₂ 5000⌋ + 1 = 13. Lesson 3.6 · 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: A) 13
Explanation: ⌊log₂ 5000⌋ + 1 = 13. Lesson 3.6 · Data Structures & Algorithms
Answer: C) Queue
Explanation: Jobs are served in arrival order. Lesson 3.2 · Data Structures & Algorithms
Answer: C) 9
Explanation: Push operands; on an operator pop two values and push the result. Answer 9. Lesson 3.2 · Data Structures & Algorithms
Answer: D) Equal keys keep their original relative order
Explanation: Stability matters when sorting records by several keys. Lesson 3.6 · Data Structures & Algorithms
Answer: D) Pre-order
Explanation: Pre-order: root, left, right. Lesson 3.3 · Data Structures & Algorithms
Answer: A) Circular queue
Explanation: It reuses freed slots at the front. Lesson 3.2 · Data Structures & Algorithms
Answer: B) Greedy algorithm
Explanation: It repeatedly merges the two least frequent symbols. Lesson 3.6 · Data Structures & Algorithms
Answer: D) O(n²)
Explanation: Keep the fastest-growing term and drop constants. Lesson 3.1 · Data Structures & Algorithms
Answer: A) 3
Explanation: 47 mod 11 = 3. Lesson 3.5 · Data Structures & Algorithms
Answer: A) O(n log n)
Explanation: Count how often the innermost statement runs as n grows: O(n log n). Lesson 3.1 · Data Structures & Algorithms
Answer: B) Sorted (ascending) order
Explanation: Left – root – right visits keys in increasing order. Lesson 3.3 · Data Structures & Algorithms
Answer: C) [1, 4, 2, 5, 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) 6
Explanation: Push operands; on an operator pop two values and push the result. Answer 6. Lesson 3.2 · Data Structures & Algorithms
Answer: D) O(n log n)
Explanation: The inner loop runs log n times for each of n outer iterations. Lesson 3.1 · Data Structures & Algorithms
Answer: D) Directed acyclic graphs
Explanation: A cycle would make an ordering impossible. Lesson 3.4 · Data Structures & Algorithms
Answer: D) 25, 15, 10, 22, 50, 35, 70
Explanation: Pre-order visits root, then left subtree, then right subtree. Lesson 3.3 · Data Structures & Algorithms
Answer: C) O(n³)
Explanation: Count how often the innermost statement runs as n grows: O(n³). Lesson 3.1 · Data Structures & Algorithms
Answer: B) O(log n)
Explanation: Count how often the innermost statement runs as n grows: O(log n). Lesson 3.1 · Data Structures & Algorithms
Answer: C) 9 and 10
Explanation: Children are at 2i + 1 and 2i + 2. Lesson 3.3 · Data Structures & Algorithms
Answer: D) 1
Explanation: The root of a min-heap is always the smallest element. Lesson 3.3 · Data Structures & Algorithms
Answer: B) 40
Explanation: Stack after all operations (bottom→top): ['30', '40']. Lesson 3.2 · Data Structures & Algorithms
Answer: A) 16, 56, 23
Explanation: Each step compares with the middle element and keeps one half. Lesson 3.6 · Data Structures & Algorithms
Answer: D) 7, 3
Explanation: Each step compares with the middle element and keeps one half. Lesson 3.6 · Data Structures & Algorithms
Answer: B) 20
Explanation: ⌊log₂ 1000000⌋ + 1 = 20. Lesson 3.6 · Data Structures & Algorithms
Answer: A) 14
Explanation: 99 mod 17 = 14. Lesson 3.5 · Data Structures & Algorithms
Practise NSCT: Data Structures & Algorithms MCQs