Question

In the dynamic programming solution for Matrix Chain Multiplication, the outermost loop iterates over the len (chain length). What are the correct loop bounds for len and i? // n is the number of matrices (arr.size() for dimensions array) // dp is a 2D array for (int len = __________) { // Line to complete len loop     for (int i = __________); i < n - len; i++) { // Line to complete i loop         int j = i + len;         // ... inner k loop and calculations     } }

A len = 1; len < n; len++ and i = 0
B len = 2; len < n; len++ and i = 0
C len = 2; len <= n; len++ and i = 1
D len = 1; len <= n; len++ and i = 1
E len = 0; len < n; len++ and i = 0
Practice Next

Hey! Ask a query