Programming C, C++, Java, PHP, Ruby, Turing, VB
Computer Science Canada 
Programming C, C++, Java, PHP, Ruby, Turing, VB  

Username:   Password: 
 RegisterRegister   
 2008 junior CCC question #4
Index -> Contests
View previous topic Printable versionDownload TopicSubscribe to this topicPrivate MessagesRefresh page View next topic
Author Message
Horus




PostPosted: Sat Dec 20, 2008 8:55 pm   Post subject: 2008 junior CCC question #4

so i was just looking at last year's question here:
http://cemc.math.uwaterloo.ca/contests/computing/2008/stage1/juniorEn.pdf

and i couldn't figure out what question #4 means.

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
Sponsor
sponsor
jbking




PostPosted: 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




PostPosted: 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




PostPosted: 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




PostPosted: 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




PostPosted: 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.
Display posts from previous:   
   Index -> Contests
View previous topic Tell A FriendPrintable versionDownload TopicSubscribe to this topicPrivate MessagesRefresh page View next topic

Page 1 of 1  [ 6 Posts ]
Jump to:   


Style:  
Search: