Hi ,
To add to your logic, I hope we must also be checking at the precedence of
the first operator that appears after the closing parenthesis ')' before we
can decided if the parenthesis can be removed or not .
On Thu, Jun 3, 2010 at 11:37 PM, Antony Vincent Pandian.S.
sant...@gmail.com wrote:
Yup... That also makes sense
If the precedence of the operator after ) is greater than the precedence of
any of the operators within (), the parenthesis should not be removed..
Thats a nice valid point...
On Fri, Jun 4, 2010 at 11:03 AM, Algoose Chase harishp...@gmail.com wrote:
Hi ,
To
Exactly that's what you need to do.
--
--
Rohit Saraf
Second Year Undergraduate,
Dept. of Computer Science and Engineering
IIT Bombay
http://www.cse.iitb.ac.in/~rohitfeb14
--
You received this message because you are subscribed to the Google
1.calculte the postfix of given expression.
2.now remove a particular parenthesis from expression and check if the
postfix of this expression is equal to the postfix of original expression.
if yes then the parenthesis we have removed were extra. if no then the
parenthesis were not exta.
3 now
You can restore the infix expression from the postfix expression
calculated, only add parenthesis when necessary in each step.
On 2010-6-3 15:35, divya jain wrote:
1.calculte the postfix of given expression.
2.now remove a particular parenthesis from expression and check if the
postfix of
Will this work ?
consider A+(B*C)
have an operator stack to hold the operators. As we scan elements from left
to right,push the operators in operator stack.
when you encounter a '(' , then scan to find the first operator that comes
after '(' (in this case *).
If this operator has a higher
A*(B+C*D)
--
--
Rohit Saraf
Second Year Undergraduate,
Dept. of Computer Science and Engineering
IIT Bombay
http://www.cse.iitb.ac.in/~rohitfeb14
--
You received this message because you are subscribed to the Google Groups
Algorithm Geeks group.
So there is a prob algoose A*(B*C) and a*(b*c+d)
i hope you understood
--
--
Rohit Saraf
Second Year Undergraduate,
Dept. of Computer Science and Engineering
IIT Bombay
http://www.cse.iitb.ac.in/~rohitfeb14
--
You received this message
Thats right !!!
On Thu, Jun 3, 2010 at 6:08 PM, Rohit Saraf rohit.kumar.sa...@gmail.comwrote:
So there is a prob algoose A*(B*C) and a*(b*c+d)
i hope you understood
--
--
Rohit Saraf
Second Year Undergraduate,
Dept. of Computer
If the base logic follows the below rule, it should work.
If any operator within parenthesis is of less precedence to the
operator before the opening parenthesis, the parenthesis can not be
removed.
For cases of equal precedence of operators before parenthesis and
within parenthesis,
10 matches
Mail list logo