The greatest mistake you can make in life is to be continually fearing you will make one

Sunday, 7 February 2010

Arithmetic Expression Evaluation

Arithmetic Expressions
  • An expression is a string of symbols 
  •  Arithmetic expressions are made up of variable names,binary operators and brackets.But in actual computer languages there are many other things such as powers(**),unary minus(-a),numbers(22/7*3.12a) and things like function(a=find(a,b)+c) and array references may be present. 
  • We are going to consider the expressions with variables(a-z),digits,binary operators(+,-,*,/) and brackets[(-left  & )-right] 
  • example of some arithmetic expression  
                 a+b-c
                 a+b+c*d
                 (a+b)*(c-d)

Types of Expression: 
  • An expression can be in 3 form
  1. Infix Expression
  2. Prefix Expression
  3. Postfix Expression 
  • Infix,prefix and postfix notations are different ways of writing expression.
  • In the 3 ways, the operands occur in the same order but the operators have to be moved. 
  • We are using infix type of expression in our daily life but the computer uses postfix or  prefix type of expression 
1.Infix Notation:
  • Operators are written in between their operands 
  • This is used in our common mathematical expressions.
  • The operations(order of evaluation) are performed from left to right. and it obeys precedence rules ie multiplication and division are performed before addition and subtraction.
  • Brackets can be used to change the order of evaluation 
  • examples 
      (a)  A+B  (b) X*(Y+Z)

2.Prefix Notation(Polish notation)
  • Operators are written before their operands
  • order of evaluation from right to left.
  • example
      (a) +AB   (b)*X+YZ

3.Postfix Notation(Reverse Polish notation) 
  • Operators are written after their operands 
  • The order of evaluation of operators is always from left to right
  • brackets cannot be used to change the order of evaluation.
  • Example
       (a) AB+,  (b) XYZ+*

Operator Precedence:

  • In the table the precedence is decreasing downwardly
  • if there are two operators with same precedence then computer start to solve the expression from left to right 
Operator
()
*,/,%
+,-


Arithmetic Expression Evaluation:
  • An important application of stacks is parsing. ie a compiler must evaluate arithmetic expressions written using infix notation.
  • The problem of parsing infix expression can be break in to 2 stages
  1. Infix to Postfix Conversion
  2. Evaluating a Postfix expression
  • Converting an infix expression in to postfix expression and evaluating a Postfix expression is a easier problem than directly evaluating Infix expression

    34 comments:

    1. very useful!!!

      ReplyDelete
    2. super but still if you give it points much better

      ReplyDelete
    3. do yu have the code?? in java

      ReplyDelete
    4. It's appropriate time to make a few plans for the long run and it is time to be happy. I've learn
      this submit and if I may just I wish to suggest you some
      interesting issues or advice. Perhaps you could write next
      articles relating to this article. I wish to learn even more things approximately it!


      Have a look at my web page pkv krankenkasse
      Feel free to visit my website :

      ReplyDelete
    5. Very descriptive blog, I loved that a lot. Will there be a part 2?


      My web blog - How to earn money through clickbank
      Here is my web site ::

      ReplyDelete
    6. Heya i'm for the first time here. I came across this board and I to find It really useful & it helped me out a lot. I am hoping to provide one thing back and aid others like you helped me.
      Feel free to visit my website :: online herrenschuhe

      ReplyDelete
    7. This is a great tip especially to those new to the blogosphere.

      Short but very accurate info… Thank you for sharing
      this one. A must read article!

      Also visit my web-site kfz kredit
      Here is my site -

      ReplyDelete
    8. I am sure this post has touched all the internet visitors, its really really
      fastidious piece of writing on building up new weblog.
      My web-site :: can i get a home equity loan with bad credit

      ReplyDelete
    9. Thank you for sharing your thoughts. I truly appreciate your efforts
      and I will be waiting for your further write ups thank you once again.
      Check out my web page ... google website Seo

      ReplyDelete
    10. Very energetic post, I enjoyed that a lot. Will
      there be a part 2?
      Also see my website - schnelle kredite ohne schufa

      ReplyDelete
    11. What's Happening i am new to this, I stumbled upon this I have found It positively useful and it has helped me out loads. I'm hoping to
      give a contribution & aid different users like
      its aided me. Good job.
      My weblog ; krankenversicherung Hunde vergleich

      ReplyDelete
    12. I comment when I especially enjoy a article on a site or I have something to add to the conversation.
      It is a result of the fire communicated in the post I browsed.
      And on this article "Arithmetic Expression Evaluation".
      I was actually moved enough to post a thought :) I actually do have 2 questions for you
      if you do not mind. Is it just me or do some of these responses look as if they are left by brain dead
      folks? :-P And, if you are posting on additional online
      social sites, I'd like to follow everything new you have to post. Could you make a list every one of your communal sites like your Facebook page, twitter feed, or linkedin profile?
      Also visit my web-site ; home based businesses

      ReplyDelete
    13. hi!,I like your writing very a lot! percentage we communicate extra
      about your post on AOL? I require a specialist on this house to solve my problem.
      May be that's you! Looking ahead to peer you.
      Also see my web page :: vergleich private krankenversicherung beamte

      ReplyDelete
    14. I just like the valuable information you provide on your articles.
      I'll bookmark your blog and take a look at once more here frequently. I'm rather certain I'll learn a lot of new stuff right right here! Best of luck for the following!
      My blog post ... online jobs at home

      ReplyDelete
    15. You're so awesome! I don't suppose I've read through a single thing like this before. So nice to find someone with some genuine thoughts on this subject matter. Seriously.. thank you for starting this up. This website is one thing that is required on the web, someone with a bit of originality!
      Review my web site :: Credit Union Private Student Loan Consolidation

      ReplyDelete
    16. I'm truly enjoying the design and layout of your site. It's a
      very easy on the eyes which makes it much more enjoyable for me to come here and
      visit more often. Did you hire out a designer to create your theme?

      Superb work!
      Also see my website > best Webhost

      ReplyDelete
    17. Hi! I know this is kind of off-topic however I had to ask.
      Does building a well-established blog such as yours require a large amount of
      work? I'm completely new to writing a blog but I do write in my journal daily. I'd like
      to start a blog so I can share my own experience and
      thoughts online. Please let me know if you have any recommendations
      or tips for brand new aspiring blog owners. Thankyou!
      My webpage ; ratgeber private krankenversicherung

      ReplyDelete
    18. My brother suggested I would possibly like this web site.

      He used to be totally right. This publish
      truly made my day. You cann't believe simply how so much time I had spent for this info! Thanks!
      Visit my web blog ... Understanding home equity loans

      ReplyDelete
    19. Hi there, i read your blog occasionally and i own a similar one and
      i was just curious if you get a lot of spam comments?
      If so how do you stop it, any plugin or anything you can advise?
      I get so much lately it's driving me mad so any assistance is very much appreciated.

      my webpage ... http://elearn.mgimo.ru/user/view.php?id=6321&course=1
      Feel free to visit my blog ... payday loans online

      ReplyDelete
    20. Hello there! This article couldn't be written any better! Looking at this article reminds me of my previous roommate! He continually kept talking about this. I am going to forward this article to him. Pretty sure he's going to have a good read.
      Thank you for sharing!

      Feel free to surf to my homepage Bonuses
      Feel free to surf my page ... http://forum.cm77.com/index.php?do=/blog/10977/fashion-and-style-suggestions-to-live-by/

      ReplyDelete
    21. I drop a comment each time I like a article on a site or I have something to valuable to contribute to the discussion.

      Usually it is triggered by the sincerness displayed in the
      article I looked at. And after this post "Arithmetic Expression Evaluation".
      I was actually moved enough to post a thought ;
      ) I do have a couple of questions for you if you do not mind.
      Could it be simply me or does it seem like a few of the remarks appear
      like they are written by brain dead individuals? :-P And, if
      you are posting at additional social sites, I'd like to keep up with everything new you have to post. Could you make a list the complete urls of all your shared pages like your linkedin profile, Facebook page or twitter feed?

      Here is my web site: please click the next website page

      ReplyDelete
    22. These are in fact impressive ideas in regarding blogging.
      You have touched some pleasant factors here. Any way keep up
      wrinting.

      Feel free to visit my blog; http://www.mi.hs-heilbronn.de/gmds-cbt/index.php?title=Benutzer:Arnoldo40

      ReplyDelete
    23. you're in point of fact a just right webmaster. The site loading speed is amazing. It kind of feels that you're doing any distinctive trick.
      Also, The contents are masterwork. you've performed a fantastic activity in this matter!

      Have a look at my page Adult All Inclusive resorts

      ReplyDelete
    24. It's enormous that you are getting ideas from this paragraph as well as from our dialogue made here.

      Also visit my blog: Home

      ReplyDelete
    25. Greetings from Colorado! I'm bored to tears at work so I decided to check out your site on my iphone during lunch break. I love the information you provide here and can't wait to take a look
      when I get home. I'm shocked at how fast your blog loaded on my cell phone .. I'm not even using WIFI,
      just 3G .. Anyhow, excellent blog!

      My website - best affiliate program

      ReplyDelete
    26. Hi there, I think your blog could possibly be having internet
      browser compatibility issues. When I look at your web site in Safari, it looks fine however when opening in Internet Explorer, it has some overlapping issues.
      I just wanted to provide you with a quick heads up! Besides that, excellent website!



      My web site: ratenzahlung trotz schufa

      ReplyDelete
    27. Great blog! Is your theme custom made or did you download it from somewhere?

      A theme like yours with a few simple adjustements would really make my blog jump out.
      Please let me know where you got your design. Cheers

      Here is my web blog :: Raspberry ketone reviews

      ReplyDelete
    28. I blog frequently and I seriously appreciate your information.
      This great article has truly peaked my interest. I am going
      to book mark your website and keep checking for new information about once per week.
      I subscribed to your RSS feed too.

      My web site: pkv für studenten

      ReplyDelete
    29. Wow, marvelous blog layout! How long have you been blogging for?
      you made blogging look easy. The overall look of your site is great, let alone the content!


      Also visit my blog :: diets that work

      ReplyDelete
    30. The report hаs provеn beneficial to me persοnallу.

      It’s extremеlу informativе and you're simply obviously really knowledgeable in this region. You have opened my own eyes for you to varying views on this particular matter together with intriguing and solid articles.

      Check out my blog phentermine
      Stop by my page ; buy phentermine

      ReplyDelete
    31. Greetings from Colorado! I'm bored at work so I decided to check out your site on my iphone during lunch break. I really like the info you present here and can't wait to take a look when I get home.
      I'm surprised at how fast your blog loaded on my mobile .. I'm not even using WIFI,
      just 3G .. Anyhow, wonderful blog!

      Feel free to surf to my homepage :: Learn more Here

      ReplyDelete
    32. The write-up features verіfied helpful tо
      us. ӏt’s really useful and yοu really аre naturаlly
      quite κnoωledgeable in this rеgion.
      You get oρened my personal sight in ordег to various thoughtѕ abοut this kіnd of topic uѕing intriguing, notable and solid wrіttеn contеnt.


      Stop by my wеb рage; ADIPEX
      My web-site ... Buy ADIPEX

      ReplyDelete