A.
A technique to store results of expensive function calls
B.
A method to sort data efficiently
C.
A way to represent data in a tree structure
D.
A technique to optimize space complexity
Solution
Memoization is a technique used in dynamic programming to store the results of expensive function calls and reuse them when the same inputs occur again.
Correct Answer:
A
— A technique to store results of expensive function calls
Q. What is the main idea behind dynamic programming?
A.
To solve problems recursively without storing results
B.
To break problems into smaller subproblems and store their solutions
C.
To use brute force to find the optimal solution
D.
To avoid using any form of recursion
Solution
Dynamic programming involves breaking a problem into smaller subproblems, solving each subproblem just once, and storing their solutions to avoid redundant computations.
Correct Answer:
B
— To break problems into smaller subproblems and store their solutions
Q. What is the primary difference between dynamic programming and divide and conquer?
A.
Dynamic programming solves problems by breaking them into independent subproblems
B.
Divide and conquer does not use recursion
C.
Dynamic programming stores solutions to subproblems, while divide and conquer does not
D.
There is no difference; they are the same
Solution
The primary difference is that dynamic programming stores solutions to subproblems to avoid redundant work, while divide and conquer typically does not.
Correct Answer:
C
— Dynamic programming stores solutions to subproblems, while divide and conquer does not
Q. What is the time complexity of the dynamic programming solution for the 0/1 Knapsack problem?
A.
O(n)
B.
O(n^2)
C.
O(n * W)
D.
O(2^n)
Solution
The time complexity of the dynamic programming solution for the 0/1 Knapsack problem is O(n * W), where n is the number of items and W is the maximum weight capacity.