CS218 Data Structures & Algorithms
Midterm Exam Review (Qns & Ans)
2025
1. Which data structure follows the Last-In-First-Out (LIFO)
principle?
A. Queue
B. Stack
C. Linked List
D. Tree
ANS: B. Stack
Rationale: A stack processes data in LIFO order, where the last
element added is the first to be removed.
2. Which algorithm is best suited for finding the shortest path in
a weighted graph?
©2025
, A. Depth-First Search (DFS)
B. Breadth-First Search (BFS)
C. Dijkstra's Algorithm
D. Kruskal's Algorithm
ANS: C. Dijkstra's Algorithm
Rationale: Dijkstra's Algorithm computes the shortest path
efficiently in graphs with positive edge weights.
3. What is the average-case time complexity of Merge Sort?
A. O(n)
B. O(n log n)
C. O(n²)
D. O(log n)
ANS: B. O(n log n)
Rationale: Merge Sort divides the array into subarrays and
merges them, leading to an average-case complexity of O(n log
n).
4. Which data structure is used to implement recursion?
A. Queue
B. Stack
©2025
, C. Heap
D. Hash Table
ANS: B. Stack
Rationale: Recursion relies on the call stack to track function
calls and their execution states.
5. Which traversal method processes nodes in the order: root, left
subtree, right subtree?
A. Inorder traversal
B. Preorder traversal
C. Postorder traversal
D. Level-order traversal
ANS: B. Preorder traversal
Rationale: Preorder traversal visits the root first, followed by
the left and right subtrees.
---
Fill-in-the-Blank Questions
6. A ________ is a data structure used to store elements in
hierarchical order, where each node has at most two children.
ANS: Binary Tree
©2025
Midterm Exam Review (Qns & Ans)
2025
1. Which data structure follows the Last-In-First-Out (LIFO)
principle?
A. Queue
B. Stack
C. Linked List
D. Tree
ANS: B. Stack
Rationale: A stack processes data in LIFO order, where the last
element added is the first to be removed.
2. Which algorithm is best suited for finding the shortest path in
a weighted graph?
©2025
, A. Depth-First Search (DFS)
B. Breadth-First Search (BFS)
C. Dijkstra's Algorithm
D. Kruskal's Algorithm
ANS: C. Dijkstra's Algorithm
Rationale: Dijkstra's Algorithm computes the shortest path
efficiently in graphs with positive edge weights.
3. What is the average-case time complexity of Merge Sort?
A. O(n)
B. O(n log n)
C. O(n²)
D. O(log n)
ANS: B. O(n log n)
Rationale: Merge Sort divides the array into subarrays and
merges them, leading to an average-case complexity of O(n log
n).
4. Which data structure is used to implement recursion?
A. Queue
B. Stack
©2025
, C. Heap
D. Hash Table
ANS: B. Stack
Rationale: Recursion relies on the call stack to track function
calls and their execution states.
5. Which traversal method processes nodes in the order: root, left
subtree, right subtree?
A. Inorder traversal
B. Preorder traversal
C. Postorder traversal
D. Level-order traversal
ANS: B. Preorder traversal
Rationale: Preorder traversal visits the root first, followed by
the left and right subtrees.
---
Fill-in-the-Blank Questions
6. A ________ is a data structure used to store elements in
hierarchical order, where each node has at most two children.
ANS: Binary Tree
©2025