1) Recursion has to be used. 2) Stack has to used 3) If any pair of paranthesis doesn't has any operator outside it, remove the pair 4) If low precedence operator is inside the pair of paranthesis than the one surrounding the pair of parenthesis, don't remove paranthesis. 5) If high precedence operator is inside the pair of paranthesis than the one surrounding the pair of parenthesis, remove paranthesis.
-Regards Amit Agarwal blog.amitagrwal.com On Fri, Oct 8, 2010 at 11:42 AM, snehal jain <[email protected]> wrote: > write a program to remove redundantt parenthesis from an expression > eg > input ((a+b)) > > output a+b > > input a+(b*c) > > output a+b*c > > input a*(b+c) > output a*(b+c) > > -- > 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.
