Algorithm for Parenthesizing equation and finding the Operator precedance

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • Siddarth777
    New Member
    • Sep 2010
    • 28

    Algorithm for Parenthesizing equation and finding the Operator precedance

    Hi,

    I have a problem, when an equation given to you, for instance,
    a*b+c/d*e-f, how do you find the operator precedance in the equation and parenthesize it accordingly?

    Is there any algorithm or such thing, which can help me do that

    Please help me

    Thanks in advance

    Siddarth777
  • zmbd
    Recognized Expert Moderator Expert
    • Mar 2012
    • 5501

    #2
    IMHO - This is a homework question; however, I think that there are some merits here for how to parse a given algebraic equation and how to implement the logic behind doing so within code. Without this basic understanding of algebraic order the rest of Mathematics is difficult at best...

    Now, as this is, IMHO, a homework question, if one of the other mods/admins would like to close the thread please do so.. I will not take offense. :)
    I just like logic puzzles and this is the best of the basic mathematics ones!

    So,
    If you'd like some help with your homework, then you are going to have to provide your work up to this point...

    Comment

    • Siddarth777
      New Member
      • Sep 2010
      • 28

      #3
      Dear zmbd,
      This is not a homework question, I am an employee working in a software Organization. Actually i am preparing for the entrance of my masters(MTECH in india), while i was going through the concept of operator precedance while parenthesizing an equation, so that i can convert it into the infix form, generate a binary tree so that i can convert it into prefix and postfix form basing on binary tree traversal

      I am really sorry if i have offended you, in any way

      A help from you for this problem is really appreciated

      Cheers
      Siddarth777

      Comment

      • zmbd
        Recognized Expert Moderator Expert
        • Mar 2012
        • 5501

        #4
        (Siddarth777) I am really sorry if i have offended you, in any way
        (Z) I think that there are some merits here for how to parse a given algebraic equation and how to implement the logic
        :) - Really, takes much more to offend me than that.... I have a wife, three children, and another on the way - :)

        INFIX - POSTFIX is certainly one way to handle this and the ease of which may well be determined by which platform you use for development.

        So that you might understand why I would get the impression that this is a homework/class project assigned either by an advanced computer science course or a masters series:

        Respectfully, as I am sure you are aware:
        Since the early event of computing, this kind of logic has been implement several times over and by the 1970's was handled quite nicely in the COBOL programing language. By the time I started programing in BASIC using the ancient CBM-PET, and later at the machine code level with the Apple series, the logic was available in the parser (but a real pain at the stack level - would often encode with BASIC and then compile to the binary level :) ). Certainly, this logic has been well implemented in spreadsheet programs since their introduction and very well established by the early 1980s as I have an AMIGA2000 that I used at the University for my Chemistry work. Would have that the statistics functions were better developed - had to derive the linear and cubic spline equations by hand for the data sets - YUCK! FORTRAN and C have this logic available in the include files. Even now I have a Hewlett Packard 26C and 32S calculators that handle such logic and these, are by today's standards, quite old. If one diligently searches the dot-edu sites on a search engine return, you can find white papers that talk about just this logic set; however, often not a level that most people will understand - even I have to re-read a few of these papers a few times to understand them.

        Once again... IMHO, this question has a great deal of merit as it is so rarely discussed outside of the Academic circles and what a great opportunity to have your work peer reviewed at a global level - something unheard of just a decade ago!

        Once again, I call for your work, keeping in mind the potential for peer review
        Last edited by zmbd; Nov 25 '12, 03:21 PM. Reason: [Z{Fixed a few typos}]

        Comment

        Working...