Question: Suppose that you are given an unparenthesized mathematical expression containing n numbers, where the only operators are + and , as shown here: 4 +

Suppose that you are given an unparenthesized mathematical expression containing n numbers, where the only operators are + and , as shown here: 4 + 3 2 5 + 1 6 + 7 You can change the value of the expression by adding parentheses in different positions. For example: 4 + 3 2 5 + 1 6 + 7 = 2 (4 + 3 (2 5)) + (1 6) + 7 = 12 (4 + (3 2)) (5 + 1) (6 + 7) = 14 For the purposes of this problem, we'll assume you can only put parentheses immediately before and immediately after a number, so that you couldn't interpret the expression multiplicatively as 4 + 3 (2) (5) + 1 6 + 7 = 36 Design an algorithm that, given an unparenthesized expression using only + and , determines the maximum possible value the expression can take when parentheses are added in. Your algorithm should run in time polynomial in n. Then: Describe your algorithm. Prove that your algorithm finds the maximum possible value the expression can take. Prove that your algorithm runs time polynomial in n.

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Databases Questions!