Data Structure MCQs (101-200)

101. A heap is a:
A) Complete binary tree
B) Full binary tree
C) Skewed binary tree
D) None
Answer: A

102. In a max-heap, the largest element is always at:
A) Root
B) Left child
C) Right child
D) Leaf
Answer: A

103. In a min-heap, the smallest element is located at:
A) Root
B) Left child
C) Right child
D) Any node
Answer: A

104. The time complexity of inserting an element into a heap is:
A) O(log n)
B) O(n)
C) O(1)
D) O(n log n)
Answer: A

105. The process of rearranging a heap after deletion is called:
A) Heapify
B) Sorting
C) Balancing
D) None
Answer: A

106. Which of the following algorithms uses heap?
A) Heap Sort
B) Quick Sort
C) Merge Sort
D) Insertion Sort
Answer: A

107. The time complexity of heap sort is:
A) O(n log n)
B) O(n²)
C) O(log n)
D) O(n)
Answer: A

108. The space complexity of heap sort is:
A) O(1)
B) O(n)
C) O(log n)
D) None
Answer: A

109. A graph is a collection of:
A) Vertices and Edges
B) Nodes only
C) Edges only
D) None
Answer: A

110. In an undirected graph, the sum of degrees of all vertices is equal to:
A) 2 × number of edges
B) Number of edges
C) Vertices × 2
D) None
Answer: A

111. A simple graph has:
A) No self-loops or multiple edges
B) Loops only
C) Multiple edges
D) None
Answer: A

112. A complete graph with n vertices has:
A) n(n – 1)/2 edges
B) n² edges
C) n – 1 edges
D) None
Answer: A

113. A graph with all vertices having equal degree is called:
A) Regular graph
B) Complete graph
C) Null graph
D) None
Answer: A

114. The degree of an isolated vertex is:
A) 0
B) 1
C) n – 1
D) None
Answer: A

115. A tree is a special kind of:
A) Graph
B) Stack
C) Queue
D) None
Answer: A

116. A tree with n vertices has how many edges?
A) n – 1
B) n
C) n + 1
D) None
Answer: A

117. A connected graph with n vertices and n – 1 edges is:
A) A tree
B) A circuit
C) A disconnected graph
D) None
Answer: A

118. A cycle in a tree:
A) Does not exist
B) Exists
C) May or may not exist
D) None
Answer: A

119. Which of the following is a traversal method for graphs?
A) BFS and DFS
B) Inorder and Postorder
C) Heapify
D) None
Answer: A

120. Breadth First Search (BFS) uses:
A) Queue
B) Stack
C) Recursion
D) None
Answer: A

121. Depth First Search (DFS) uses:
A) Stack or Recursion
B) Queue
C) Linked List
D) None
Answer: A

122. Time complexity of BFS is:
A) O(V + E)
B) O(V²)
C) O(E²)
D) None
Answer: A

123. Time complexity of DFS is:
A) O(V + E)
B) O(V²)
C) O(E²)
D) None
Answer: A

124. A graph with no edges is called:
A) Null graph
B) Tree
C) Simple graph
D) None
Answer: A

125. An adjacency matrix representation of a graph requires:
A) O(V²) space
B) O(E) space
C) O(V + E) space
D) None
Answer: A

126. An adjacency list representation of a graph requires:
A) O(V + E) space
B) O(V²) space
C) O(E²) space
D) None
Answer: A

127. A disconnected graph has:
A) More than one component
B) Only one component
C) No vertices
D) None
Answer: A

128. A directed graph is also called a:
A) Digraph
B) Loop graph
C) Weighted graph
D) None
Answer: A

129. The shortest path algorithm by Dijkstra is used for:
A) Weighted graphs
B) Unweighted graphs
C) Trees only
D) None
Answer: A

130. In Dijkstra’s algorithm, the data structure often used is:
A) Priority Queue
B) Stack
C) Array
D) None
Answer: A

131. Kruskal’s algorithm is used to find:
A) Minimum Spanning Tree (MST)
B) Shortest Path
C) Topological Order
D) None
Answer: A

132. Prim’s algorithm also finds:
A) Minimum Spanning Tree (MST)
B) Longest Path
C) BFS traversal
D) None
Answer: A

133. Topological sorting can be applied only to:
A) Directed Acyclic Graphs (DAGs)
B) Undirected graphs
C) Trees
D) None
Answer: A

134. The number of edges in a complete undirected graph of 5 vertices is:
A) 10
B) 15
C) 5
D) None
Answer: A

135. Hashing is used for:
A) Fast data retrieval
B) Sorting
C) Traversal
D) None
Answer: A

136. A hash function maps keys to:
A) Hash table index
B) Values
C) Buckets only
D) None
Answer: A

137. Collision occurs in hashing when:
A) Two keys map to the same index
B) Two keys map to different indices
C) Index is empty
D) None
Answer: A

138. One method to handle collision is:
A) Chaining
B) Deletion
C) Rotation
D) None
Answer: A

139. Linear probing suffers from:
A) Primary clustering
B) Secondary clustering
C) No clustering
D) None
Answer: A

140. Quadratic probing reduces:
A) Primary clustering
B) Secondary clustering
C) Both
D) None
Answer: A

141. The load factor in hashing is defined as:
A) n / table size
B) table size / n
C) n² / table size
D) None
Answer: A

142. Binary search requires:
A) Sorted array
B) Unsorted array
C) Linked list
D) None
Answer: A

143. Time complexity of binary search is:
A) O(log n)
B) O(n)
C) O(n log n)
D) None
Answer: A

144. Linear search has a time complexity of:
A) O(n)
B) O(log n)
C) O(1)
D) None
Answer: A

145. Which searching algorithm works for linked lists?
A) Linear search
B) Binary search
C) Jump search
D) None
Answer: A

146. Bubble sort works by:
A) Repeatedly swapping adjacent elements
B) Dividing array into halves
C) Using pivot element
D) None
Answer: A

147. Time complexity of bubble sort (worst case):
A) O(n²)
B) O(log n)
C) O(n)
D) O(n log n)
Answer: A

148. Selection sort finds:
A) Minimum element and places it in correct position
B) Maximum element and deletes it
C) Median element
D) None
Answer: A

149. Time complexity of insertion sort (average case):
A) O(n²)
B) O(log n)
C) O(n)
D) O(n log n)
Answer: A

150. Merge sort uses which technique?
A) Divide and Conquer
B) Greedy
C) Dynamic Programming
D) None
Answer: A

151. Quick sort uses which technique?
A) Divide and Conquer
B) Greedy
C) Dynamic Programming
D) Backtracking
Answer: A

152. The worst-case time complexity of quick sort is:
A) O(n²)
B) O(n log n)
C) O(n)
D) O(log n)
Answer: A

153. The average-case time complexity of quick sort is:
A) O(n log n)
B) O(n²)
C) O(log n)
D) O(n³)
Answer: A

154. Which sorting algorithm is the most efficient for large datasets?
A) Merge Sort
B) Bubble Sort
C) Insertion Sort
D) Selection Sort
Answer: A

155. Which sorting algorithm is stable?
A) Merge Sort
B) Quick Sort
C) Heap Sort
D) Selection Sort
Answer: A

156. Counting sort is best suited for:
A) Small integer keys
B) Large string data
C) Floating point numbers
D) None
Answer: A

157. The space complexity of merge sort is:
A) O(n)
B) O(1)
C) O(log n)
D) None
Answer: A

158. The sorting algorithm with the best average performance is:
A) Merge Sort
B) Quick Sort
C) Bubble Sort
D) Insertion Sort
Answer: B

159. Which sorting algorithm works in-place?
A) Quick Sort
B) Merge Sort
C) Counting Sort
D) None
Answer: A

160. Radix sort is based on:
A) Digit position processing
B) Divide and conquer
C) Swapping adjacent elements
D) Comparison-based method
Answer: A

161. Bucket sort works best when data is:
A) Uniformly distributed
B) Randomly distributed
C) Sorted
D) None
Answer: A

162. Which sorting algorithm does not use comparison?
A) Counting Sort
B) Quick Sort
C) Merge Sort
D) Heap Sort
Answer: A

163. The time complexity of radix sort is:
A) O(nk)
B) O(n log n)
C) O(n²)
D) O(k log n)
Answer: A

164. Stability in sorting algorithms means:
A) Equal elements retain their relative order
B) Order changes randomly
C) Fastest sort
D) None
Answer: A

165. Which sorting algorithm is not stable?
A) Heap Sort
B) Merge Sort
C) Insertion Sort
D) Bubble Sort
Answer: A

166. In-place sorting means:
A) Uses constant extra space
B) Uses no comparisons
C) Uses recursion
D) None
Answer: A

167. The master theorem is used for analyzing:
A) Divide and Conquer algorithms
B) Dynamic algorithms
C) Recursive backtracking
D) None
Answer: A

168. Recursion uses which data structure?
A) Stack
B) Queue
C) Heap
D) Tree
Answer: A

169. Tail recursion can be replaced by:
A) Iteration
B) Stack
C) Queue
D) None
Answer: A

170. Base condition in recursion is used to:
A) Stop recursion
B) Increase calls
C) Randomize
D) None
Answer: A

171. Infinite recursion leads to:
A) Stack overflow
B) Memory leak
C) Queue overflow
D) None
Answer: A

172. The time complexity of recursive Fibonacci without memoization is:
A) O(2ⁿ)
B) O(n)
C) O(n²)
D) None
Answer: A

173. Recursive functions are always slower than:
A) Iterative functions
B) Stack operations
C) Array traversals
D) None
Answer: A

174. Memoization is used to:
A) Store intermediate results
B) Repeat computation
C) Increase recursion depth
D) None
Answer: A

175. Dynamic programming is based on:
A) Overlapping subproblems and optimal substructure
B) Randomization
C) Divide and Conquer
D) None
Answer: A

176. The time complexity of binary search tree operations (average case) is:
A) O(log n)
B) O(n)
C) O(1)
D) None
Answer: A

177. In an unbalanced BST, search time may degrade to:
A) O(n)
B) O(log n)
C) O(1)
D) None
Answer: A

178. Amortized analysis is used for:
A) Average performance over multiple operations
B) Worst-case per operation
C) Best-case only
D) None
Answer: A

179. Which of the following data structures provides LIFO access?
A) Stack
B) Queue
C) Linked List
D) Array
Answer: A

180. Which of the following provides FIFO access?
A) Queue
B) Stack
C) Tree
D) None
Answer: A

181. Priority queues can be implemented using:
A) Heaps
B) Stacks
C) Arrays
D) None
Answer: A

182. The maximum number of children in a binary tree node is:
A) 2
B) 3
C) 4
D) None
Answer: A

183. Which traversal can be used to print nodes level by level?
A) Level order
B) Inorder
C) Postorder
D) Preorder
Answer: A

184. The number of leaf nodes in a complete binary tree with n nodes is approximately:
A) n/2
B) log n
C) n²
D) None
Answer: A

185. The height of a complete binary tree with n nodes is:
A) ⌊log₂n⌋
B) n
C) n/2
D) None
Answer: A

186. The maximum number of nodes at height h in a binary tree is:
A) 2ʰ
B) h²
C) log₂h
D) None
Answer: A

187. A graph traversal algorithm that can detect cycles is:
A) DFS
B) BFS
C) Both
D) None
Answer: A

188. A minimum spanning tree contains:
A) All vertices with minimum total edge weight
B) All edges
C) Cycles
D) None
Answer: A

189. The number of edges in a tree with n vertices is always:
A) n – 1
B) n
C) n + 1
D) None
Answer: A

190. Which algorithm is used to find shortest path in weighted graphs?
A) Dijkstra’s algorithm
B) Kruskal’s algorithm
C) Prim’s algorithm
D) None
Answer: A

191. Which algorithm is used to find shortest path from all nodes to all nodes?
A) Floyd-Warshall
B) Dijkstra’s
C) Kruskal’s
D) None
Answer: A

192. Topological sort can only be applied to:
A) Directed Acyclic Graphs (DAGs)
B) Trees
C) Undirected graphs
D) None
Answer: A

193. Which data structure is used in Dijkstra’s algorithm?
A) Priority Queue
B) Stack
C) Tree
D) None
Answer: A

194. Which traversal technique can find connected components in a graph?
A) DFS
B) BFS
C) Both
D) None
Answer: C

195. A spanning tree with minimum total edge cost is called:
A) Minimum Spanning Tree
B) Optimal Tree
C) Binary Tree
D) None
Answer: A

196. Which graph traversal is best for finding the shortest path in unweighted graphs?
A) BFS
B) DFS
C) Dijkstra’s
D) Kruskal’s
Answer: A

197. An adjacency list is preferred over adjacency matrix when:
A) Graph is sparse
B) Graph is dense
C) Edges > Vertices²
D) None
Answer: A

198. A full binary tree with 7 internal nodes has how many leaves?
A) 8
B) 7
C) 6
D) None
Answer: A

199. The number of nodes in a perfect binary tree of height h is:
A) 2^(h+1) – 1
B) h²
C) h × 2
D) None
Answer: A

200. A data structure that allows elements to be added or removed from both ends is:
A) Deque
B) Stack
C) Queue
D) None
Answer: A

Leave a Comment

Your email address will not be published. Required fields are marked *

You cannot copy content of this page

Scroll to Top