[algogeeks] Re: finding duplicate set of paranthesis

2011-12-11 Thread Gene
We talked about the problem of removing as many parentheses as possible: http://groups.google.com/group/algogeeks/browse_thread/thread/26ce36ad34dce9dc/e8fb40ab2ba0ecc0 You didn't define duplicate. For (a*b)+c, the parens don't add any information. Should they be removed? The algorithm given

[algogeeks] Re: finding duplicate set of paranthesis

2011-12-10 Thread Lucifer
@rahul... If you are plan to just find out the no. of duplicate parenthesis, then that would be ( No. of open Parenthesis - No. of Operators + 1) On Dec 10, 10:22 pm, rahul venkat rahul911...@gmail.com wrote: hi everyone, can u suggest an algorithm for finding the duplicate paranthesis in a

[algogeeks] Re: finding duplicate set of paranthesis

2011-12-10 Thread Lucifer
@rahul.. there is one exception to the above rule and that is the case with unary minus operator.. for ex : a + (-c) + d will need one parentheses, but a + ( -c + d ) will only need 1 instead of 2.. But for the sake of unary minus u can assume that it will be enclosed within a parenthesis.. On

[algogeeks] Re: finding duplicate set of paranthesis

2011-12-10 Thread Lucifer
@rahul Algo for identifying the exact set of parenthesis to be removed would be: Take a stack named 'IndStk' to hold the indices of opening parenthesis. When a '(' parenthesis is encountered push it onto the stack and if a ')' parenthesis is encountered then pop from the top of the stack ( i.e