wu :: forums
« wu :: forums - REMOVE PARENTHESES »

Welcome, Guest. Please Login or Register.
Apr 19th, 2024, 12:49pm

RIDDLES SITE WRITE MATH! Home Home Help Help Search Search Members Members Login Login Register Register
   wu :: forums
   riddles
   microsoft
(Moderators: Grimbal, SMQ, Eigenray, ThudnBlunder, Icarus, towr, william wu)
   REMOVE PARENTHESES
« Previous topic | Next topic »
Pages: 1  Reply Reply Notify of replies Notify of replies Send Topic Send Topic Print Print
   Author  Topic: REMOVE PARENTHESES  (Read 11024 times)
arvindwu
Newbie
*





   


Gender: male
Posts: 1
REMOVE PARENTHESES  
« on: Nov 1st, 2008, 1:56am »
Quote Quote Modify Modify

how to remove redundent parentheses  
 
(A+B) = A+B  
(A+(B*C) )  = A+B*C
((A+B)*C)  = (A+B)*C
A/(B+C)  = A/(B+C)
IP Logged
towr
wu::riddles Moderator
Uberpuzzler
*****



Some people are average, some are just mean.

   


Gender: male
Posts: 13730
Re: REMOVE PARENTHESES  
« Reply #1 on: Nov 1st, 2008, 4:13am »
Quote Quote Modify Modify

Build a tree from the expression, and then use precedence rules:
 
C\P +  -  *  /
+:  _  r  lr lr
-:  _  r  lr lr
*:  _  _  _  r
/:  _  _  _  r

 
e.g. If the parent node (P) has the operator *, then a child (C) with operator + needs to be enveloped in parentheses when it's either the left (l) or right (r) child.
If the parent node (P) has the operator /, then a child (C) with operator * needs to be enveloped in parentheses only if it's the right (r) child, but not when it's the left (l).
« Last Edit: Nov 1st, 2008, 4:14am by towr » IP Logged

Wikipedia, Google, Mathworld, Integer sequence DB
towr
wu::riddles Moderator
Uberpuzzler
*****



Some people are average, some are just mean.

   


Gender: male
Posts: 13730
Re: REMOVE PARENTHESES  
« Reply #2 on: Apr 5th, 2013, 6:21am »
Quote Quote Modify Modify

I'm getting the distinct impression you're just spamming... I can't remember any of your posts contributing anything, it's all "I agree", "thanks", "I didn't know that".
IP Logged

Wikipedia, Google, Mathworld, Integer sequence DB
Grimbal
wu::riddles Moderator
Uberpuzzler
*****






   


Gender: male
Posts: 7526
Re: REMOVE PARENTHESES  
« Reply #3 on: Apr 7th, 2013, 7:09am »
Quote Quote Modify Modify

Me too.  I even started to removed this kind of posts where there is no contribution to the subject.
 
PS: oops, I was cleaning up this kind of messages and I accidentally deleted the message you were commenting on.
 
For info, towr was replying to Mariko79 who just quoted towr's previous message and said something like "Thanks, buddy".
« Last Edit: Apr 7th, 2013, 8:56am by Grimbal » IP Logged
Pages: 1  Reply Reply Notify of replies Notify of replies Send Topic Send Topic Print Print

« Previous topic | Next topic »

Powered by YaBB 1 Gold - SP 1.4!
Forum software copyright © 2000-2004 Yet another Bulletin Board