WGU D446 DATA STRUCTURES AND
ALGORITHMS II PRACTICE EXAM
QUESTIONS AND ANSWERS
1. What is the worst-case time complexity of the Quicksort algorithm?
A. O(n log n)
B. O(n^2)
C. O(log n)
D. O(n)
Answer: B
Conceptual Explanation: Quicksort has a worst-case time complexity of O(n^2) when the
pivot selection consistently results in highly unbalanced partitions, such as when the array
is already sorted and the first or last element is chosen as the pivot.
2. Which of the following data structures is typically used to implement Breadth-First Search
(BFS)?
A. Stack
B. Priority Queue
C. Binary Search Tree
,D. Queue
Answer: D
Conceptual Explanation: BFS uses a FIFO (First-In-First-Out) queue to track nodes that
have been discovered but not yet processed, ensuring nodes are visited level by level.
3. What is the primary difference between Dijkstra’s algorithm and the Bellman-Ford
algorithm?
A. Bellman-Ford can detect negative cycles and handle negative weights, while Dijkstra’s
cannot.
B. Dijkstra’s is only for undirected graphs.
C. Dijkstra’s can handle negative edge weights, while Bellman-Ford cannot.
D. Bellman-Ford is faster than Dijkstra’s for all graph types.
Answer: A
Conceptual Explanation: Bellman-Ford is more versatile as it can handle negative edge
weights and detect negative cycles, whereas Dijkstra’s requires all edge weights to be non-
negative.
4. In a max-heap, where is the largest element located?
A. At a leaf node
B. At the last index of the array
C. In the middle of the array
, D. At the root node
Answer: D
Conceptual Explanation: The defining property of a max-heap is that the parent node is
always greater than or equal to its children, meaning the largest value is always at the root.
5. What is the height of a balanced AVL tree with n nodes?
A. O(n)
B. O(log n)
C. O(n log n)
D. O(1)
Answer: B
Conceptual Explanation: AVL trees maintain a strict balance factor (difference in height of
subtrees is at most 1), ensuring the height remains logarithmic relative to the number of
nodes.
6. Which algorithm design paradigm does the Merge Sort algorithm follow?
A. Greedy
B. Divide and Conquer
C. Dynamic Programming
D. Backtracking
ALGORITHMS II PRACTICE EXAM
QUESTIONS AND ANSWERS
1. What is the worst-case time complexity of the Quicksort algorithm?
A. O(n log n)
B. O(n^2)
C. O(log n)
D. O(n)
Answer: B
Conceptual Explanation: Quicksort has a worst-case time complexity of O(n^2) when the
pivot selection consistently results in highly unbalanced partitions, such as when the array
is already sorted and the first or last element is chosen as the pivot.
2. Which of the following data structures is typically used to implement Breadth-First Search
(BFS)?
A. Stack
B. Priority Queue
C. Binary Search Tree
,D. Queue
Answer: D
Conceptual Explanation: BFS uses a FIFO (First-In-First-Out) queue to track nodes that
have been discovered but not yet processed, ensuring nodes are visited level by level.
3. What is the primary difference between Dijkstra’s algorithm and the Bellman-Ford
algorithm?
A. Bellman-Ford can detect negative cycles and handle negative weights, while Dijkstra’s
cannot.
B. Dijkstra’s is only for undirected graphs.
C. Dijkstra’s can handle negative edge weights, while Bellman-Ford cannot.
D. Bellman-Ford is faster than Dijkstra’s for all graph types.
Answer: A
Conceptual Explanation: Bellman-Ford is more versatile as it can handle negative edge
weights and detect negative cycles, whereas Dijkstra’s requires all edge weights to be non-
negative.
4. In a max-heap, where is the largest element located?
A. At a leaf node
B. At the last index of the array
C. In the middle of the array
, D. At the root node
Answer: D
Conceptual Explanation: The defining property of a max-heap is that the parent node is
always greater than or equal to its children, meaning the largest value is always at the root.
5. What is the height of a balanced AVL tree with n nodes?
A. O(n)
B. O(log n)
C. O(n log n)
D. O(1)
Answer: B
Conceptual Explanation: AVL trees maintain a strict balance factor (difference in height of
subtrees is at most 1), ensuring the height remains logarithmic relative to the number of
nodes.
6. Which algorithm design paradigm does the Merge Sort algorithm follow?
A. Greedy
B. Divide and Conquer
C. Dynamic Programming
D. Backtracking