For this specific case since only 2 operators are used : + , * and we know that * is the operator that maximizes the value(provided both the operands are not equal to one / none of the operand is zero and also given that operands are +ve ). Doing * operation as late as possible should suffice right ?
For Eg: Do all additions in the first pass and do all multiplications in 2nd pass. is there be any case where the above mentioned logic fails ? On Wed, Nov 24, 2010 at 4:07 PM, Amir hossein Shahriari < [email protected]> wrote: > you can use an algorithm similar to matrix chain multiplication i.e. if > dp[i][j] is the maximum value that you can get with the numbers v_i to v_j > and in order to maximize it find k that maximizes ( dp[i][k] op_k dp[k][j] > ) > v_i is the ith value and op_k is the kth operator > obviously if i==j : dp[i][j] = v_i > > -- > You received this message because you are subscribed to the Google Groups > "Algorithm Geeks" group. > To post to this group, send email to [email protected]. > To unsubscribe from this group, send email to > [email protected]<algogeeks%[email protected]> > . > For more options, visit this group at > http://groups.google.com/group/algogeeks?hl=en. > -- You received this message because you are subscribed to the Google Groups "Algorithm Geeks" group. To post to this group, send email to [email protected]. To unsubscribe from this group, send email to [email protected]. For more options, visit this group at http://groups.google.com/group/algogeeks?hl=en.
