Welcome to the Java Programming Forums


The professional, friendly Java community. 21,500 members and growing!


The Java Programming Forums are a community of Java programmers from all around the World. Our members have a wide range of skills and they all have one thing in common: A passion to learn and code Java. We invite beginner Java programmers right through to Java professionals to post here and share your knowledge. Become a part of the community, help others, expand your knowledge of Java and enjoy talking with like minded people. Registration is quick and best of all free. We look forward to meeting you.


>> REGISTER NOW TO START POSTING


Members have full access to the forums. Advertisements are removed for registered users.

Results 1 to 3 of 3

Thread: Stacks (evaluating postfix expression)

  1. #1
    Junior Member
    Join Date
    Jan 2012
    Posts
    21
    My Mood
    Confused
    Thanks
    5
    Thanked 1 Time in 1 Post

    Default Stacks (evaluating postfix expression)

    I'm a little confused so if someone can confirm if I am doing that would be great.

    Evaluate postfix expression:

    1 2 + 4 * 5 6 * 10 / 8 * +

    Me evaluating:

    1) 1
    2) 2 1
    3) 3
    4) 4 3
    5) 12
    6) 5 12
    7) 6 5 12
    8) 30 12
    9) 10 30 12
    10) Here's where I get confused. Do I do 30/10 or 10/30 (and is it the same way for subtraction)...3 12
    11) 8 3 12
    12) 24 12
    13) 36


  2. #2
    Super Moderator helloworld922's Avatar
    Join Date
    Jun 2009
    Posts
    2,896
    Thanks
    23
    Thanked 619 Times in 561 Posts
    Blog Entries
    18

    Default Re: Stacks (evaluating postfix expression)

    From Wikipedia:

    Operations which are non-commutative are still written in "conventional order", i.e.:

    a b op = a op b

    4 2 / = 4 / 2 = 2
    2 4 / = 2 / 4 = 0.5

  3. The Following User Says Thank You to helloworld922 For This Useful Post:

    dx8292 (October 6th, 2012)

  4. #3
    Junior Member
    Join Date
    Jan 2012
    Posts
    21
    My Mood
    Confused
    Thanks
    5
    Thanked 1 Time in 1 Post

    Default Re: Stacks (evaluating postfix expression)

    Quote Originally Posted by helloworld922 View Post
    From Wikipedia:

    Operations which are non-commutative are still written in "conventional order", i.e.:

    a b op = a op b

    4 2 / = 4 / 2 = 2
    2 4 / = 2 / 4 = 0.5
    So I guess 36 is right, thanks

Similar Threads

  1. [SOLVED] EVALUATION OF POSTFIX NOTATION
    By Medo Almasry in forum What's Wrong With My Code?
    Replies: 6
    Last Post: November 7th, 2011, 05:24 PM
  2. POSTFIX NOTATION USING STACKS... [EXAM IN 4 HRS HELP!!!]
    By Medo Almasry in forum What's Wrong With My Code?
    Replies: 7
    Last Post: October 23rd, 2011, 12:16 AM
  3. [SOLVED] evaluating postfix expressions using stack
    By lieles in forum What's Wrong With My Code?
    Replies: 4
    Last Post: March 16th, 2011, 11:48 AM
  4. [SOLVED] Help with prefix and postfix(increment&decrement)
    By Lokesh in forum Object Oriented Programming
    Replies: 1
    Last Post: February 12th, 2011, 10:20 AM
  5. convert infix to postfix
    By tina G in forum Algorithms & Recursion
    Replies: 2
    Last Post: March 11th, 2010, 01:46 AM