MCQs / Computer Science / NSCT: Data Structures & Algorithms

NSCT: Data Structures & Algorithms MCQs — Computer Science (page 4)

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.

76. An undirected graph has 7 edges. The sum of the degrees of all vertices is:

  1. 49
  2. 7
  3. 21
  4. 14

Answer: D) 14

Explanation: Each edge adds 2 to the total degree. Lesson 3.4 · Data Structures & Algorithms

Discuss this question

77. What is the maximum number of comparisons binary search needs to find an item in a sorted array of 64 elements?

  1. 14
  2. 7
  3. 32
  4. 4

Answer: B) 7

Explanation: ⌊log₂ 64⌋ + 1 = 7. Lesson 3.6 · Data Structures & Algorithms

Discuss this question

78. Which algorithm handles negative edge weights and detects negative cycles?

  1. Prim
  2. BFS
  3. Dijkstra
  4. Bellman-Ford

Answer: D) Bellman-Ford

Explanation: Bellman-Ford relaxes all edges V − 1 times. Lesson 3.4 · Data Structures & Algorithms

Discuss this question

79. A max-heap contains 20, 15, 30, 5, 25. After deleting the root once, which value becomes the new root?

  1. 15
  2. 30
  3. 5
  4. 25

Answer: D) 25

Explanation: Deleting the maximum leaves the second largest at the root. Lesson 3.3 · Data Structures & Algorithms

Discuss this question

80. For a sparse graph, the most memory-efficient representation is:

  1. Incidence matrix
  2. Adjacency matrix
  3. Adjacency list
  4. Edge table sorted by weight

Answer: C) Adjacency list

Explanation: It uses O(V + E) space. Lesson 3.4 · Data Structures & Algorithms

Discuss this question

81. A doubly linked list differs from a singly linked list because each node has:

  1. Two data fields
  2. No pointer
  3. Pointers to both next and previous nodes
  4. A pointer to the head only

Answer: C) Pointers to both next and previous nodes

Explanation: Traversal is possible in both directions. Lesson 3.2 · Data Structures & Algorithms

Discuss this question

82. The load factor of a hash table is:

  1. Table size ÷ keys
  2. Size of each key
  3. Number of collisions
  4. Number of keys ÷ table size

Answer: D) Number of keys ÷ table size

Explanation: α = n/m. Lesson 3.5 · Data Structures & Algorithms

Discuss this question

83. Merge sort follows which design technique?

  1. Backtracking
  2. Greedy
  3. Dynamic programming
  4. Divide and conquer

Answer: D) Divide and conquer

Explanation: Divide the list, sort halves, merge. Lesson 3.6 · Data Structures & Algorithms

Discuss this question

84. Keys 15, 11, 27, 8, 12 are inserted in this order into a hash table of size 7 using h(k) = k mod 7 and linear probing. At which index is 12 stored?

  1. 4
  2. 0
  3. 5
  4. 6

Answer: C) 5

Explanation: Final table: [None, 15, 8, None, 11, 12, 27]. Lesson 3.5 · Data Structures & Algorithms

Discuss this question

85. In a max-heap, the largest element is always at the:

  1. Leftmost leaf
  2. Last leaf
  3. Middle of the array
  4. Root

Answer: D) Root

Explanation: Each parent is ≥ its children. Lesson 3.3 · Data Structures & Algorithms

Discuss this question

86. Evaluate the postfix expression: 8 2 3 -

  1. 3
  2. 4
  3. 1
  4. 2

Answer: D) 2

Explanation: Push operands; on an operator pop two values and push the result. Answer 2. Lesson 3.2 · Data Structures & Algorithms

Discuss this question

87. A heap is usually stored in a/an:

  1. Stack
  2. Linked list
  3. Array
  4. Hash table

Answer: C) Array

Explanation: A complete binary tree maps neatly to array indices. Lesson 3.3 · Data Structures & Algorithms

Discuss this question

88. A complete undirected graph with 6 vertices has how many edges?

  1. 12
  2. 30
  3. 15
  4. 36

Answer: C) 15

Explanation: n(n − 1)/2 = 15. Lesson 3.4 · Data Structures & Algorithms

Discuss this question

89. Starting with an empty queue, these operations are performed: enqueue A, enqueue B, enqueue C, dequeue, dequeue, enqueue D. Which element is at the front?

  1. D
  2. B
  3. C
  4. A

Answer: C) C

Explanation: Queue after all operations (front→rear): ['C', 'D']. Lesson 3.2 · Data Structures & Algorithms

Discuss this question

90. Keys 15, 10, 20, 8, 12, 25 are inserted in this order into an empty binary search tree. What is the pre-order traversal?

  1. 8, 12, 10, 25, 20, 15
  2. 8, 10, 12, 15, 20, 25
  3. 15, 10, 8, 12, 20, 25
  4. 25, 12, 8, 20, 10, 15

Answer: C) 15, 10, 8, 12, 20, 25

Explanation: Pre-order visits root, then left subtree, then right subtree. Lesson 3.3 · Data Structures & Algorithms

Discuss this question

91. What is the maximum number of comparisons binary search needs to find an item in a sorted array of 1,024 elements?

  1. 512
  2. 8
  3. 22
  4. 11

Answer: D) 11

Explanation: ⌊log₂ 1024⌋ + 1 = 11. Lesson 3.6 · Data Structures & Algorithms

Discuss this question

92. Keys 8, 3, 10, 1, 6, 14 are inserted in this order into an empty binary search tree. What is the pre-order traversal?

  1. 14, 6, 1, 10, 3, 8
  2. 1, 3, 6, 8, 10, 14
  3. 8, 3, 1, 6, 10, 14
  4. 1, 6, 3, 14, 10, 8

Answer: C) 8, 3, 1, 6, 10, 14

Explanation: Pre-order visits root, then left subtree, then right subtree. Lesson 3.3 · Data Structures & Algorithms

Discuss this question

93. Keys 15, 10, 20, 8, 12, 25 are inserted in this order into an empty binary search tree. What is the post-order traversal?

  1. 15, 10, 8, 12, 20, 25
  2. 8, 10, 12, 15, 20, 25
  3. 25, 20, 15, 12, 10, 8
  4. 8, 12, 10, 25, 20, 15

Answer: D) 8, 12, 10, 25, 20, 15

Explanation: Post-order visits left, right, then root – the first key inserted (root) comes last. Lesson 3.3 · Data Structures & Algorithms

Discuss this question

94. When two keys map to the same index, it is called a:

  1. Overflow
  2. Deadlock
  3. Rotation
  4. Collision

Answer: D) Collision

Explanation: Collisions must be resolved. Lesson 3.5 · Data Structures & Algorithms

Discuss this question

95. Keys 23, 43, 13, 27 are inserted in this order into a hash table of size 10 using h(k) = k mod 10 and linear probing. At which index is 27 stored?

  1. 6
  2. 8
  3. 7
  4. 9

Answer: C) 7

Explanation: Final table: [None, None, None, 23, 43, 13, None, 27, None, None]. Lesson 3.5 · Data Structures & Algorithms

Discuss this question

96. After the FIRST pass of selection sort (ascending) on [5, 1, 4, 2, 8], the list is:

  1. [1, 2, 4, 5, 8]
  2. [1, 5, 4, 2, 8]
  3. [8, 2, 4, 1, 5]
  4. [1, 4, 2, 5, 8]

Answer: B) [1, 5, 4, 2, 8]

Explanation: Selection sort swaps the minimum into position 0. Lesson 3.6 · Data Structures & Algorithms

Discuss this question

97. Linear probing suffers from:

  1. Fragmentation of disk
  2. Primary clustering
  3. Starvation
  4. Stack overflow

Answer: B) Primary clustering

Explanation: Runs of filled slots grow and slow down searches. Lesson 3.5 · Data Structures & Algorithms

Discuss this question

98. Binary search (mid = (low + high) // 2) looks for 70 in [10, 20, 30, 40, 50, 60, 70, 80]. Which sequence of middle elements is compared?

  1. 70, 60, 40
  2. 40, 60, 70
  3. 10, 20, 30
  4. 40, 60, 70, 80

Answer: B) 40, 60, 70

Explanation: Each step compares with the middle element and keeps one half. Lesson 3.6 · Data Structures & Algorithms

Discuss this question

99. A queue follows which principle?

  1. LIFO
  2. FILO
  3. FIFO
  4. Priority order

Answer: C) FIFO

Explanation: First in, first out. Lesson 3.2 · Data Structures & Algorithms

Discuss this question

100. Which complexity grows the fastest?

  1. O(n log n)
  2. O(2ⁿ)
  3. O(n³)
  4. O(n²)

Answer: B) O(2ⁿ)

Explanation: Exponential growth overtakes any polynomial. Lesson 3.1 · Data Structures & Algorithms

Discuss this question

Previous Page 4 of 6 Next

Practise NSCT: Data Structures & Algorithms MCQs

More Computer Science chapters