i pretty much get polish notation but i don't understand how postfix notation works...
and btw does --3+219 means (-3)-(2+1+9) ?
just making sure...
Sponsor Sponsor
jbking
Posted: Sat Dec 20, 2008 10:06 pm Post subject: RE:2008 junior CCC question #4
Not quite....
Remember that - a b means a - b and - + a b c means a+b - c as the + a b is evaluated first and then that answer is used an input for the next operator.
- - 3 + 2 1 9
which equals :- - 3 (2+1) 9
which equals: - (3 - (2+1)) 9
which equals: 3 - (2+1) - 9 in infix notation which is different than you wrote.
Horus
Posted: Sat Dec 20, 2008 10:16 pm Post subject: RE:2008 junior CCC question #4
oh ok, kinda get it now
but what about postfix notation?
OneOffDriveByPoster
Posted: Sat Dec 20, 2008 10:49 pm Post subject: Re: RE:2008 junior CCC question #4
Horus @ Sat Dec 20, 2008 10:16 pm wrote:
oh ok, kinda get it now
but what about postfix notation?
Postfix is like how old calculators work:
3 2 -
means you are calculating (3 - 2); the calculation happens as soon as the operator (-) is used.
3 2 - 1 + would be (3 - 2) + 1.
3 2 - 1 9 * + would be (3 - 2) + (1 * 9).
Horus
Posted: Sat Dec 20, 2008 10:54 pm Post subject: RE:2008 junior CCC question #4
ok thx i finally understand it now. now i can finally code haha.
lol if this type of question appears on CCC in 2009 i'm probably screwed...
Euphoracle
Posted: Sun Dec 21, 2008 12:31 am Post subject: RE:2008 junior CCC question #4
When I did this, I was silly, and I converted it to our "regular" notation (in a sense), and then to the target format. I found it easier to work with a format I was comfortable with, and, although it wasn't the most efficient way of doing it, it got the job done correctly. I probably should have kept those solutions. Oh well.