Q. In dynamic programming, what is the purpose of memoization?
-
A.
To sort data
-
B.
To store intermediate results
-
C.
To optimize space complexity
-
D.
To reduce time complexity
Solution
Memoization is used to store intermediate results of subproblems to avoid redundant calculations and improve efficiency.
Correct Answer:
B
— To store intermediate results
Learn More →
Q. What is the main idea behind the Bellman-Ford algorithm in dynamic programming?
-
A.
To find the shortest path in a graph
-
B.
To sort a list of numbers
-
C.
To find the maximum flow in a network
-
D.
To compute the Fibonacci sequence
Solution
The Bellman-Ford algorithm is used to find the shortest path from a single source vertex to all other vertices in a weighted graph.
Correct Answer:
A
— To find the shortest path in a graph
Learn More →
Q. What is the primary advantage of using dynamic programming over naive recursion?
-
A.
It is easier to implement
-
B.
It uses less memory
-
C.
It avoids redundant calculations
-
D.
It is faster for all problems
Solution
The primary advantage of dynamic programming is that it avoids redundant calculations by storing the results of subproblems.
Correct Answer:
C
— It avoids redundant calculations
Learn More →
Showing 1 to 3 of 3 (1 Pages)