Translation Software (Cambridge (CIE) A Level Computer Science): Exam Questions

Exam code: 9618

41 mins6 questions
1a4 marks

Several syntax diagrams are shown.

Flowchart with categories: letter (A, E, I, O, U, Y), symbol (#, $, ?, &, @), operator (+, -, *, /), digit (0-9); label and equation processes.

Complete the Backus-Naur Form (BNF) for the given syntax diagrams.

<operator> ::= ..................................................

<label> ::= ........................................................

<equation> ::= ..................................................

1b5 marks

A new syntax rule, password, is required. It must begin with a letter or a symbol, followed by a digit and end with one or two symbols.

(i) Draw a syntax diagram for password.

(3)

(ii) Write the BNF for password.

(2)

2a2 marks

Several syntax diagrams are shown.

Flowchart illustrating categorisation of odd, even, symbols, and letters with arrows indicating progression. Second diagram classifies numbers by odd and even.

State why each number is invalid for the given syntax diagrams.

21

Reason ..................................................

123

Reason ..................................................

2b2 marks

Complete the Backus‑Naur Form (BNF) for the given syntax diagrams

<symbol> ::= ....................................

<number> ::= ....................................

2c5 marks

A new syntax rule, code, is required. It must begin with a letter, followed by one or two numbers, and end with a symbol.

(i) Draw a syntax diagram for code.

(3)

(ii) Write the BNF for code.

(2)

3a3 marks

Write this Reverse Polish Notation (RPN) in infix form:

5 2 + 9 3 - / 3 *

3b2 marks

Write this infix expression in RPN:

((7 + 3) - (2 * 8)) / 6

3c4 marks

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.

Twelve columns of identical vertical grids, each divided into four equal rectangles, aligned in a row against a plain background.
4a2 marks

Write this infix expression in Reverse Polish Notation (RPN):

(7 – 2 + 8) / (9 – 5)

4b4 marks

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.

Thirteen vertical columns of equal-sized rectangles, each containing four stacked smaller rectangles, evenly spaced in rows.
4c3 marks

Write this RPN expression in infix form:

b a c - + d b + * c /

52 marks

Write the infix expression for this Reverse Polish Notation (RPN) expression:

5 2 – 5 4 + * 9 /

63 marks

Explain how an expression stored in RPN can be evaluated.