Pre Post and Infix Notations

Please download to get full document.

View again

of 12
All materials on our website are shared by users. If you have any questions about copyright issues, please report us to resolve them. We are always happy to assist you.
Similar Documents
Information Report
Category:

Documents

Published:

Views: 19 | Pages: 12

Extension: PDF | Download: 0

Share
Description
Arithmetic Expressions ã (a + b) * (c + d) + e – f/g*h + 3.25 ã Expressions comprise three kinds of entities. – Operators (+, - / *) (+ -, /, ). – Operands (a, b, c, d, e, f, g, h, 3.25, (a + b), (c + d), etc.). d) etc ) – Delimiters ((, )). Evaluation of Expressions Operator Degree ã Number of operands that the operator requires. i ã Binary operator requires two operands. y p q p –a+b –c/d –e-f Infix Form ã Normal way to write an expression. ã Binary operators come in between their left and
Tags
Transcript
  Evaluation of Expressions  ã(a + b) * (c + d) + e – f/g*h + 3.25ãExpressions comprise three kinds of entities. * – ,-, , .  –Operands (a,b,c,d,e,f ,g,h,3.25,(a + b),(c + ,.. –Delimiters ((,)).   ãNumber of operands that the operator requres.ãBinary operator requires two operands.  –a + b –c/d     –e -f  .  –+ g –-   ãNormal way to write an expression.ãBinary operators comeinbetween their left.  –a * b –a + c –a * b / c –(a + b) * (c + d) + e – f/g*h + 3.25    ãHow do you figure out the operands of anoperaor   –a + b * c –a * b + c / d ãThisisdonebassininoerator  priorities.  –*=>=-    ãWhen an operand lies between two,operator that has higher priority. ++  ãWhen evaluating Priority Operator 1 Unary minus, !  same priorities, it 2 *, /, %  from left to right. , - 4 <, <=, >=, > ã  –Nonzero as true 5 ==(equal), != 6 &&and –zero as false –!3&&5 +1  0 7 ||(or)   ãx=6, y=5ã+*+   ã(x>=5)&&y<10ã!x>10+!y   ãWhen an operand lies between twooperators that have the same priority, theoerand associates with the oerator onthe left.  –- –a * b / c / d  Delimiters ãSubexpression within delimiters istreated as a single operand,indeendent from the remainder of theexpression. * –  –   –   ãNeed operator priorities, tie breaker,an emers.ãThis makes computer evaluation more   difficult than is necessary.ã not rely on operator priorities, a tie, .ãSo it is easier for a computer toforms.   constant is the same as its infix form.  –a,b,3.25 ãsame in infix and postfix forms.ãperaors come mmeaeyaer epostfix form of their operands.  –Infix= a + b –= ãInfix =a + b * c  –Postfix= abc*+ ãInfix =a * b + c  Postfix =ab*c+ ãInfix = (a + b) * (c –d) / (e + f)  Postfix =ab+cd-*ef+/     ãReplace with new symbols.  –+ a => a @ –++=>+  –-a => a ? –-a- = a -   Expressions are converted into Postfix notation before.X = A / B –C + D * E –A * CInfix=> A / B –C + D * E –A * CPostfix => A B / C –D E * + A C * - (Operators come in-between operands)(Operators come after operands) OperationPostfixT 1 = A / BT 1 C –D E * + A C * -T 2 = T 1 -CT 2 D E * + A C * -T 3 = D * ET 2 T 3 + A C * -T 4 = T 2 + T 3 T 4 A C * -T 5 = A * CT 4 T 5 -T 6 = T 4 -T 5 T 6   ãScan postfix expression from left to rightpusng operans on o a sac.ãWhen an operator is encountered, popas many operands as this operator needs; evaluate the oerator; ush theresult on to the stack.ã , ,operators come immediately after their .   ã(a + b) * (c – d) / (e + f)ãa b + c d -* e f + /*- ãa b+ c d -* e f + / ãa b +c d -* e f + / astack 
Recommended
View more...
We Need Your Support
Thank you for visiting our website and your interest in our free products and services. We are nonprofit website to share and download documents. To the running of this website, we need your help to support us.

Thanks to everyone for your continued support.

No, Thanks
SAVE OUR EARTH

We need your sign to support Project to invent "SMART AND CONTROLLABLE REFLECTIVE BALLOONS" to cover the Sun and Save Our Earth.

More details...

Sign Now!

We are very appreciated for your Prompt Action!

x