Discover the depth  of  C

  C C++  Linux ProgrammingNEW   Operating Systems  Data StructuresNEW  Compilers  Contact Us

Navigation

Join C4SwimmersGroup

 sitepromotion.gif (577 bytes) New Member

Data Structures

  Introduction

Stacks

  About Stacks

  Types of Notations

  Infix to Postfix

  Infix to Prefix

  Evaluating Postfix

Queues

  About Queues
  Circular Queue
  Priority Queue
Linked Lists 
 About Linked Lists
 Singly Lists
 Doubly Lists
 Circular Lists
 Circular Doubly Lists
Sorting
 Bubble Sort
 Insertion Sort
 Selection Sort
 Shell Sort
 Merge Sort
 Quick Sort
Searching
 About Searching
 Linear Search
 Binary Search
Online Certifications
premiumservices.gif (1070 bytes) Brainbench
premiumservices.gif (1070 bytes) Benchmarks Global
Help and Support
customer_care_small.gif (1018 bytes) Suggestions
post-question_icon.gif (1062 bytes) Contribute
premiumservices.gif (1070 bytes) Feedback
premiumservices.gif (1070 bytes) Advertise with us
 

 memberhome.gif (1052 bytes) -Home Page-

 
 
.  

C For Swimmers : Mastering C step-by-step

Google


WWW c4swimmers.esmartguy.com

Notations

 

Types of Notations : 

  • Infix notation
  • Prefix notation
  • Postfix notation

Consider the sum of A and B. We think of applying the operator “+” to the operands A and B to write the sum as A+B. This particular representation is called Infix notation. There are two alternate notations for expressing the sum of A and B using the symbols A, B and +. These are
+ A B Prefix notation
A B + Postfix notation

The prefixes “pre-“, “post-“ and “in-“ refer to the relative position of the operator with respect to the two operands.
In Prefix notation the operator precede the two operands,
In Postfix notation the operator follows the two operands and
In Infix notation the operator is between the two operands.

The evaluation of the expression A + B * C, as written in standard infix notation, requires knowledge of which of the two operations, + or *, is to be performed first. In the case of + and *, we “know” that multiplication is to be done before addition (in the absence of parenthesis to the contrary). Thus A+B*C is interpreted as A + ( B * C ) unless otherwise specified. We say that multiplication takes precedence over addition. Suppose that we want to rewrite A + B * C in postfix. Applying the rules of precedence, we first convert the portion of the expression that is evaluated first, namely the multiplication. By doing this conversion in stages, we obtain :
A + ( B * C ) Paranthesis for emphasis
A + ( BC* ) Convert the multiplication
A ( BC* ) + Convert the addition
ABC*+ Postfix form

The only rules to remember during the conversion process are that operations with highest precedence are converted first and that after a portion of the expression has been converted to postfix, it is to be treated as a single operand. Consider the same example with the precedence of operators reversed by the deliberate insertion of paranthesis.
( A + B ) * C Infix form
( AB+ ) * C Convert the addition
( AB+ ) C * Convert the multiplication
AB+C* Postfix form

In the above example the addition is converted before the multiplication because of the parenthesis. In going from ( A + B ) * C to ( AB+ ) * C, A and B are the operands and + is the operator. In going from ( AB+ ) * C to ( AB+ ) C *, ( AB+ ) and C are the operands and * is the operator. The rules for converting from infix to postfix are simple, providing that you know the order of precedence.


You are Visitor No.

Sign my Guestbook View my Guestbook

Subscribe to C4Swimmers Group
Designed and Maintained by  Nanda Kishor

Thanks for using C For Swimmers.
Regarding this material, you can send Bug Reports, Suggestions, Comments, etc. to

nandakishorkn@rediffmail.com

Note: All logos or trademarks are related to their respective owners.

Although every precaution has been taken, the designer(s) owe no responsibility for malicious errors.

No liability assumed for damages resulting from the use of the available information.