Hard_Level_MCQs_Data_Structures_Algorithms
Hard_Level_MCQs_Data_Structures_Algorithms
and Algorithms
1. 1. What is the primary advantage of using an expression tree over a standard binary
tree for evaluating mathematical expressions?
Answer: B
2. 2. Given an expression tree where each leaf node contains a number and each internal
node contains an operator, what traversal method is used to evaluate the expression?
A) Preorder
B) Inorder
C) Postorder
D) Level-order
Answer: C
3. 3. In an expression tree, which traversal method gives the infix notation of the
expression?
A) Preorder
B) Inorder
C) Postorder
D) Level-order
Answer: B
A) Polynomial expressions
B) Logical expressions
C) Set expressions
D) Regular expressions
Answer: D
5. 5. If an expression tree has a depth of d, what is the time complexity of evaluating the
expression?
A) O(d)
B) O(d^2)
C) O(2^d)
D) O(log d)
Answer: A
6. 6. In a binary tree, if you perform an inorder traversal and receive the output as sorted,
what does this indicate?
Answer: C
A) Level-order
B) Preorder
C) Postorder
D) Both B and C
Answer: D
8. 8. For a complete binary tree with n nodes, what is the time complexity of a level-order
traversal?
A) O(n)
B) O(log n)
C) O(n log n)
D) O(n^2)
Answer: A
9. 9. Which of the following statements is true for preorder traversal in a binary tree?
Answer: B
10. 10. In which traversal technique are nodes visited in the order "Left, Root, Right"?
A) Inorder
B) Preorder
C) Postorder
D) Level-order
Answer: A
11. 11. What is the maximum height of an AVL tree with n nodes?
A) O(n)
B) O(log n)
C) O(n log n)
D) O(sqrt(n))
Answer: B
A) When the height difference between left and right subtrees exceeds 1
B) When the height difference between left and right subtrees is 0
C) When the height difference between left and right subtrees exceeds 2
D) When the height difference between left and right subtrees is 1
Answer: A
13. 13. In an AVL tree, what type of rotation is required if an insertion causes a right-right
(RR) imbalance?
A) Right Rotation
B) Left Rotation
C) Left-Right Rotation
D) Right-Left Rotation
Answer: B
14. 14. In which situation would you apply a double rotation on an AVL tree?
A) Right-Right imbalance
B) Left-Left imbalance
C) Left-Right or Right-Left imbalance
D) When the tree is already balanced
Answer: C
15. 15. What is the balance factor of a node in an AVL tree that has a left subtree of height 3
and a right subtree of height 1?
A) 3
B) 1
C) -2
D) 2
Answer: D
16. 16. Which hashing technique allows elements with the same hash value to be stored in a
linked list at each index of the hash table?
A) Linear Probing
B) Chaining
C) Double Hashing
D) Quadratic Probing
Answer: B
17. 17. What is the main issue that occurs in a hash table when two elements are hashed to
the same index?
A) Clustering
B) Chaining
C) Collision
D) Overloading
Answer: C
18. 18. Which of the following hashing techniques can reduce primary clustering?
A) Linear Probing
B) Quadratic Probing
C) Double Hashing
D) Both B and C
Answer: D
19. 19. In a hash table, which method is used to handle collisions by searching linearly
through the table?
A) Linear Probing
B) Quadratic Probing
C) Chaining
D) Rehashing
Answer: A
Answer: A
21. 21. Which graph traversal algorithm is typically used for finding the shortest path in an
unweighted graph?
A) Depth-First Search
B) Breadth-First Search
C) Dijkstra’s Algorithm
D) Floyd-Warshall Algorithm
Answer: B
22. 22. What is the time complexity of Depth-First Search (DFS) in an adjacency list
representation of a graph with V vertices and E edges?
A) O(V + E)
B) O(V^2)
C) O(V^2 + E)
D) O(E)
Answer: A
23. 23. Which traversal algorithm is most suitable for detecting cycles in an undirected
graph?
A) Breadth-First Search
B) Depth-First Search
C) Prim’s Algorithm
D) Kruskal’s Algorithm
Answer: B
24. 24. In a Depth-First Search (DFS) traversal of a graph, what data structure is typically
used to keep track of the traversal path?
A) Queue
B) Stack
C) Array
D) Linked List
Answer: B
25. 25. Which algorithm is more efficient for finding a Minimum Spanning Tree (MST) in a
dense graph?
A) Prim’s Algorithm
B) Kruskal’s Algorithm
C) Dijkstra’s Algorithm
D) Bellman-Ford Algorithm
Answer: A