l ynbrook c omputer s cience member meeting, november 10, 2008
TRANSCRIPT
![Page 1: L YNBROOK C OMPUTER S CIENCE Member Meeting, November 10, 2008](https://reader036.vdocuments.us/reader036/viewer/2022062511/5513de3155034679748b5302/html5/thumbnails/1.jpg)
LYNBROOK COMPUTER SCIENCEMember Meeting, November 10, 2008
![Page 2: L YNBROOK C OMPUTER S CIENCE Member Meeting, November 10, 2008](https://reader036.vdocuments.us/reader036/viewer/2022062511/5513de3155034679748b5302/html5/thumbnails/2.jpg)
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!
![Page 3: L YNBROOK C OMPUTER S CIENCE Member Meeting, November 10, 2008](https://reader036.vdocuments.us/reader036/viewer/2022062511/5513de3155034679748b5302/html5/thumbnails/3.jpg)
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.)
![Page 4: L YNBROOK C OMPUTER S CIENCE Member Meeting, November 10, 2008](https://reader036.vdocuments.us/reader036/viewer/2022062511/5513de3155034679748b5302/html5/thumbnails/4.jpg)
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
![Page 5: L YNBROOK C OMPUTER S CIENCE Member Meeting, November 10, 2008](https://reader036.vdocuments.us/reader036/viewer/2022062511/5513de3155034679748b5302/html5/thumbnails/5.jpg)
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
![Page 6: L YNBROOK C OMPUTER S CIENCE Member Meeting, November 10, 2008](https://reader036.vdocuments.us/reader036/viewer/2022062511/5513de3155034679748b5302/html5/thumbnails/6.jpg)
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
![Page 7: L YNBROOK C OMPUTER S CIENCE Member Meeting, November 10, 2008](https://reader036.vdocuments.us/reader036/viewer/2022062511/5513de3155034679748b5302/html5/thumbnails/7.jpg)
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
![Page 8: L YNBROOK C OMPUTER S CIENCE Member Meeting, November 10, 2008](https://reader036.vdocuments.us/reader036/viewer/2022062511/5513de3155034679748b5302/html5/thumbnails/8.jpg)
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?
![Page 9: L YNBROOK C OMPUTER S CIENCE Member Meeting, November 10, 2008](https://reader036.vdocuments.us/reader036/viewer/2022062511/5513de3155034679748b5302/html5/thumbnails/9.jpg)
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
![Page 10: L YNBROOK C OMPUTER S CIENCE Member Meeting, November 10, 2008](https://reader036.vdocuments.us/reader036/viewer/2022062511/5513de3155034679748b5302/html5/thumbnails/10.jpg)
PREFIX/INFIX/POSTFIX NOTATION
Translate the following from prefix to postfix:
- + * 2 x * 3 y z
![Page 11: L YNBROOK C OMPUTER S CIENCE Member Meeting, November 10, 2008](https://reader036.vdocuments.us/reader036/viewer/2022062511/5513de3155034679748b5302/html5/thumbnails/11.jpg)
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 -
![Page 12: L YNBROOK C OMPUTER S CIENCE Member Meeting, November 10, 2008](https://reader036.vdocuments.us/reader036/viewer/2022062511/5513de3155034679748b5302/html5/thumbnails/12.jpg)
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!