Find the Minimum and Maximum values of given expression with + and *

Find the Minimum and Maximum values of given expression with + and *

Program to find the minimum and maximum values of given expression is discussed here.

Given an algebraic expression with + and *, find the minimum and maximum values.

Minimum and Maximum values of given expression with + and *


For example:

Sample Input:

1+2*3+4*5

Sample Output:

27

105

Explanation:

1 + (2 * 3) + (4 * 5) = 27 (Minimum)

(1 + 2) * (3 + 4) * 5 = 105 (Maximum)

Algorithm to find the minimum and maximum values of given expression with + and *

  • Separate the operators and numbers from the given expression.
  • Two 2D arrays are taken for storing the intermediate result which is updated.
  • Different parenthesization is tried among the numbers in accordance with the operators occurring between them.
  • Store the minimum value in the last cell of the 1st array and the maximum value in the last cell of the 2nd array.


face prep pro ad bannerClick here to learn more about FACE Prep PRO


Program to find the minimum and maximum values of given expression with + and *

@@coding::1@@


Recommended Programs


Minimum and Maximum values of given expression with + and *

c