16.2 Translation Software
A Level · 3 questions found
What this topic covers
Section titled “What this topic covers”- How an interpreter executes programs without a translated version
- Compilation stages: lexical analysis, syntax analysis, code generation, optimisation
- Grammar notation: syntax diagrams and Backus-Naur Form (BNF)
- Reverse Polish Notation (RPN) for expression evaluation
Past paper questions
Section titled “Past paper questions” Q5

5
(a) Write this Reverse Polish Notation (RPN) in infix form:
5 2 + 9 3 - / 3 *
............................................................................................................................................. [3]
(b) Write this infix expression in RPN:
((7 + 3) - (2 * 8)) / 6
............................................................................................................................................. [2]
(c) Evaluate this RPN expression:
a b - c d + * e /
when
a = 17, b = 5, c = 7, d = 3 and e = 10
Show the changing contents of the stack as the RPN expression is evaluated.
[4]
Show mark scheme
5(a) [3 marks]
mark per correct term (
Max 3)
(5 + 2)
/ (9 – 3)
Complete correct answer
((5 + 2) / (9 - 3)) * 3
Max 3)
(5 + 2)
/ (9 – 3)
Complete correct answer
((5 + 2) / (9 - 3)) * 3
5(b) [2 marks]
mark
7 3 +
mark
2 8 * - 6 /
Complete answer
7 3 + 2 8 * - 6 /
7 3 +
mark
2 8 * - 6 /
Complete answer
7 3 + 2 8 * - 6 /
5(c) [4 marks]
mark per ring (
Max 4)
3
5
7
7
10
10
17
17
12
12
12
12
120
120
12
Max 4)
3
5
7
7
10
10
17
17
12
12
12
12
120
120
12
Q5

5
(a) Write this infix expression in Reverse Polish Notation (RPN):
(7 – 2 + 8) / (9 – 5)
............................................................................................................................................. [2]
(b) Evaluate this RPN expression:
a d + a b + c - *
when
a = 6, b = 3, c = 7 and d = 9
Show the changing contents of the stack as the RPN expression is evaluated.
[4]
(c) Write this RPN expression in infix form:
b a c - + d b + * c /
............................................................................................................................................. [3]
Show mark scheme
5(a) [2 marks]
mark
7 2 – 8 +
mark
9 5 - /
Complete answer
7 2 – 8 + 9 5 - /
7 2 – 8 +
mark
9 5 - /
Complete answer
7 2 – 8 + 9 5 - /
5(b) [4 marks]
mark per ring (
Max 4)
3
7
9
6
6
9
9
2
6
6
15
15
15
15
15
15
30
Max 4)
3
7
9
6
6
9
9
2
6
6
15
15
15
15
15
15
30
5(c) [3 marks]
mark per correct term (
Max 3)
(a – c + b)
* (d + b)
Complete correct answer
(((a – c) + b) * (d + b))/c
(a – c + b) * (d + b)/c
Max 3)
(a – c + b)
* (d + b)
Complete correct answer
(((a – c) + b) * (d + b))/c
(a – c + b) * (d + b)/c
Q5

5
(a) Write this Reverse Polish Notation (RPN) in infix form:
5 2 + 9 3 - / 3 *
............................................................................................................................................. [3]
(b) Write this infix expression in RPN:
((7 + 3) - (2 * 8)) / 6
............................................................................................................................................. [2]
(c) Evaluate this RPN expression:
a b - c d + * e /
when
a = 17, b = 5, c = 7, d = 3 and e = 10
Show the changing contents of the stack as the RPN expression is evaluated.
[4]
,
,
Show mark scheme
5(a) [3 marks]
mark per correct term (
Max 3)
(5 + 2)
/ (9 – 3)
Complete correct answer
((5 + 2) / (9 - 3)) * 3
Max 3)
(5 + 2)
/ (9 – 3)
Complete correct answer
((5 + 2) / (9 - 3)) * 3
5(b) [2 marks]
mark
7 3 +
mark
2 8 * - 6 /
Complete answer
7 3 + 2 8 * - 6 /
7 3 +
mark
2 8 * - 6 /
Complete answer
7 3 + 2 8 * - 6 /
5(c) [4 marks]
mark per ring (
Max 4)
3
5
7
7
10
10
17
17
12
12
12
12
120
120
12
Max 4)
3
5
7
7
10
10
17
17
12
12
12
12
120
120
12