1 / 12

Lynbrook Computer Science

Lynbrook Computer Science. Member Meeting, November 10, 2008. Upcoming Competitions. Today: USACO November Round 11/12 (Wed): TopCoder SRM Round 12/5-12/8 (Fri-Mon): USACO December Round 12/15 (Mon): ACSL Contest #1 Check http://LynbrookCS.com for full ACSL and USACO schedules!.

micah
Download Presentation

Lynbrook Computer Science

An Image/Link below is provided (as is) to download presentation Download Policy: Content on the Website is provided to you AS IS for your information and personal use and may not be sold / licensed / shared on other websites without getting consent from its author. Content is provided to you AS IS for your information and personal use only. Download presentation by click this link. While downloading, if for some reason you are not able to download a presentation, the publisher may have deleted the file from their server. During download, if you can't get a presentation, the file might be deleted by the publisher.

E N D

Presentation Transcript


  1. Lynbrook Computer Science Member Meeting, November 10, 2008

  2. Upcoming Competitions • Today: USACO November Round • 11/12 (Wed): TopCoder SRM Round • 12/5-12/8 (Fri-Mon): USACO December Round • 12/15 (Mon): ACSL Contest #1 • Check http://LynbrookCS.com for full ACSL and USACO schedules!

  3. Tested Material on the ACSL • What does this program do? • Number Systems (different base operations) • Recursive Functions (f(x) = f(x-1) + 1) • Boolean Algebra (not A + B = …) • Bit String Flicking (right shift, left shift) • LISP Evaluation (ADD, SUB, DIV, MULT) • Digital Electronics (AND, OR, XOR, NAND, NOR, XNOR) • Prefix/Infix/Postfix Notation (+ 3 4) • Data Structures (heaps, binary trees, stacks, etc.)

  4. What does this program do? • Usually written in an easy-to-understand language such as BASIC or Pascal • Trick is to read the code as if it were in english, and then evaluate the operations as they come. • program S(input, output); var a,b:integer; begin a:=0; b:=0; for a:=0 to 5 do begin b:=b+1; end; end; • Simple evaluation leads us to b = 6

  5. Infix Notation • Operators are written in-between operands • Exactly like normal mathematical evaluation • A * ( B + C ) / D • First add B to C • Then multiply the result by A • Then divide by D

  6. Prefix Notation • Operators are written before their operands • Trick is to group them with parenthesis, then convert into infix notation, and evaluate • / * A + B C D • (/ (* A (+ B C) ) D ) • Infix notation: A * (B + C) / D

  7. Postfix Notation • Operators are written after their operands • Trick is to group them with parenthesis, then convert into infix notation, and evaluate • A B C + * D / • ( (A (B C +) *) D / ) • Infix notation: A * (B + C) / D

  8. What does this program do? • program SR(input,output); var a,b,c,x:integer; begin b:=0; for a:=1 to 5 do begin x:=0; while x <= 5 do begin c:=5; repeat b:=b+c; c:=c-1; until c=0; x:=x+1; end; end end; What is the final value of b after SR is executed?

  9. Solution • 1. Read code as if it were in english • 2. Translate code into math • ( ( 5+4+3+2+1 ) * 6 ) * 5 • 3. Evaluate mathematical operation • = (15) * 6 * 5 • =15 * 30 • = 450

  10. Prefix/Infix/Postfix Notation • Translate the following from prefix to postfix: • - + * 2 x * 3 y z

  11. Solution • 1. Group problem with parenthesis • (- (+ (* 2 x)(* 3 y)) z) • 2. Translate problem into infix notation • (((2 * x) +(3 * y)) - z) • 3. Work backwards to translate from infix notation to postfix notation • (((2 x *)(3 y *) +) z -) • 2 x * 3 y * + z -

  12. Miscellaneous • Remember to sign in! • Don’t forget to turn in your check ($15, payable to Lynbrook ASB) if you haven’t done so already! • Remember to take the USACO (ends today)! • Check http://LynbrookCS.com for updates • Don’t forget to review the material we covered today – it comes up on the ACSL!

More Related