CS6515 Exam 3 Actual Exam 2026/2027 –
Complete Exam-Style Questions with
Detailed Rationales | 100% Verified – Pass
Guaranteed – A+ Graded
Dynamic Programming & Divide and Conquer
Q1: Which of the following statements best distinguishes the Divide and Conquer paradigm from
Dynamic Programming?
A. Divide and Conquer solves problems by iterating through the solution space, whereas
Dynamic Programming uses recursion to break problems down.
B. Divide and Conquer combines solutions to overlapping subproblems, whereas Dynamic
Programming combines solutions to independent subproblems.
C. Divide and Conquer breaks the problem into independent subproblems, whereas Dynamic
Programming breaks the problem into overlapping subproblems. [CORRECT]
D. Divide and Conquer always runs in polynomial time, whereas Dynamic Programming is
generally restricted to exponential time complexity.
Correct Answer: C
Rationale: The core difference is that Divide and Conquer solves independent subproblems (like
in Merge Sort), while Dynamic Programming is specifically designed for problems with
overlapping subproblems (like in the Floyd-Warshall algorithm) to avoid redundant calculations.
Q2: Consider the recurrence relation T(n) = 4T(n/2) + n² log n. Which case of the Master
Theorem applies, and what is the resulting complexity?
A. Case 1, because f(n) = O(n^(log_b a - ε)), resulting in Θ(n²).
B. Case 2, because f(n) = Θ(n^(log_b a) log^k n), resulting in Θ(n² log² n). [CORRECT]
C. Case 3, because f(n) = Ω(n^(log_b a + ε)), resulting in Θ(n² log n).
D. The Master Theorem does not apply because the regularity condition in Case 3 cannot be
verified.
,2
Correct Answer: B
Rationale: Here, a=4 and b=2, so log_b a = 2. Since f(n) = n² log n matches the form Θ(n² log^k
n) with k=1, this falls into Master Theorem Case 2, resulting in a complexity of Θ(n² log² n).
Q3: You are analyzing Strassen's Matrix Multiplication algorithm. If the recurrence is given by
T(n) = 7T(n/2) + O(n²), why is this algorithm preferred over the standard O(n³) approach for
large matrices?
A. The log_b a term is log_2 7 ≈ 2.81, which is significantly less than 3, offering better
asymptotic performance. [CORRECT]
B. The constant factors in the O(n²) term are negligible, making the linear term dominate.
C. Strassen's algorithm utilizes cache-oblivious properties that standard multiplication lacks.
D. The recurrence solves to Θ(n log n), which is the theoretical lower bound for matrix
multiplication.
Correct Answer: A
Rationale: Strassen's algorithm reduces the number of recursive multiplications from 8 to 7,
changing the exponent in the solution from log_2 8 = 3 to log_2 7 ≈ 2.81, which is
asymptotically faster than the standard Θ(n³) approach.
Q4: Suppose you are designing a Dynamic Programming solution for the Longest Common
Subsequence (LCS) of two strings X of length m and Y of length n. You decide to use a 2D table
DP[i][j]. What is the exact recurrence relation for filling this table?
A. If X[i] == Y[j], DP[i][j] = 1 + DP[i-1][j-1]; else DP[i][j] = max(DP[i-1][j], DP[i][j-1]).
[CORRECT]
B. If X[i] == Y[j], DP[i][j] = DP[i-1][j-1]; else DP[i][j] = 1 + max(DP[i-1][j], DP[i][j-1]).
C. DP[i][j] = max(DP[i-1][j], DP[i][j-1], DP[i-1][j-1]) regardless of character equality.
D. DP[i][j] = 1 + min(DP[i-1][j], DP[i][j-1]) only if X[i] == Y[j].
Correct Answer: A
, 3
Rationale: This is the standard recurrence for LCS; if characters match, we extend the length of
the LCS found for the previous prefixes; if they don't match, we take the maximum LCS length
obtained by ignoring one character from either string.
Q5: In the context of Dynamic Programming, what is "optimal substructure"?
A. A property where a problem can be solved by combining optimal solutions to non-overlapping
subproblems. [CORRECT]
B. A technique where the solution space is searched greedily to find a local optimum.
C. The requirement that the problem size must be a power of two for the recursion to work.
D. The property that the number of subproblems is polynomial in the input size.
Correct Answer: A
Rationale: Optimal substructure means that an optimal solution to the problem contains within it
optimal solutions to subproblems, which allows us to build up the solution from the bottom up or
via memoization.
Q6: You are given a sequence of matrices A₁, A₂, ..., Aₙ with dimensions p₀, p₁, ..., pₙ where
matrix Aᵢ has dimensions pᵢ₋₁ × pᵢ. What is the time complexity of finding the optimal
parenthesization for matrix chain multiplication using Dynamic Programming?
A. O(n log n)
B. O(n²)
C. O(n³) [CORRECT]
D. O(2ⁿ)
Correct Answer: C
Rationale: The standard Matrix Chain Multiplication DP algorithm uses two nested loops to fill
an n×n table, and each entry calculation takes O(n) time in the worst case, leading to a total time
complexity of Θ(n³).