I found this when looking for problems with dynamic programming. You are given a non-parameterized expression of the form V0 O0 V1 O1 .... Vn-1
We need to put brackets in places that maximize the meaning of the whole expression.
V are operands, and O are operators. In the first version, problematic operators can be * and +, and operands are positive. The second version of the problem is completely general.
For the first version, I came up with a DP solution.
Solution - A [] = array of operands B [] - array of operators T (A [i, j]) - the maximum value of the expression T (A [0, n-1]) = max for all i ((T (A [0 , i]) Oi T (A [i + 1, n-1]))}
The boundary cases are trivial (when i = j). I need help with the following: Analyze the running time of this algorithm. And if there is a better one.
performance optimization algorithm expression dynamic-programming
Nitin garg
source share