Professional Documents
Culture Documents
American Computer Science League Senior Division Solutions 1. Data Structures 2007 - 2008 Contest #4
American Computer Science League Senior Division Solutions 1. Data Structures 2007 - 2008 Contest #4
1. Data Structures
1. 38
C
D L S
E I N S
2. Data Structures 2. S
The stack is constructed as follows:
BLE, BL, LB, LBAK, KABL, KA, AK, AKH, A, AO, OA, O, OSE,
ESO, ES. The next popped item is S since stacks are LIFO.
3. Prefix-Infix-Postfix
3. As Shown
prefix: / * + A B – B C A C infix: ( (A+B)*(B+C))/(AC)
postfix: A B + B C - * A C /
4. Prefix-Infix-Postfix 4. 16
4 3 * 9 7 + % 4 5 + 2 3 5 * @ / = (4*3)(9+7) %(4+ 5 )2 (3 *5) @ /
= ( 12 % 16 ) (9 2 ) 15 @ / = 48 ( 81@ 15 ) /
= 48 / 3 = 16