Operating systems and translation software – A Level Computer Science (9618)
43 questions · page 3 of 3
Question text
6
(a) The Reverse Polish Notation (RPN) expression:
a b * 2 / c d / *
is to be evaluated where a = 20, b = 3, c = 10 and d = 5.
Show the changing contents of the following stack as the RPN expression is evaluated.
[4]
(b) Explain how an expression stored in RPN can be evaluated.
…
…
…
…
…
… [3]
Question text
6
Several syntax diagrams are shown.
operator
digit
+
0
–
1
*
2
/
3
symbol
4
$
5
%
6
&
7
@
8
#
letter
9
A
D
P
R
Y
password
letter
digit
symbol
(a) State whether each of the following passwords is valid or invalid and give a reason for your
choice.
DPAD99$ …
Reason …
…
DAD#95 …
Reason …
…
ADY123? …
Reason …
…
[3]
(b) Complete the Backus-Naur Form (BNF) for the syntax diagrams shown.
<symbol> ::= …
…
<letter> ::= …
…
[1]
(c) An identifier begins with one or more letters, followed by zero digits or one digit or more
digits.
Valid letters and digits are shown in the syntax diagrams on page 6.
Draw a syntax diagram for an identifier.
[4]
Question text
3
Several syntax diagrams are shown.
digit
letter
0
A
1
C
2
E
3
G
4
I
5
K
6
M
7
O
8
Q
9
S
U
W
Y
variable
letter
digit
(a) State whether each variable is valid or invalid and give a reason for your choice in each case.
9SW …
Reason …
…
UWY …
Reason …
…
[2]
(b) <word> contains one or more letters.
Complete the Backus‑Naur Form (BNF) for <word> and use this to complete the BNF for
<variable>.
<word> ::= …
…
<variable> ::= …
…
[3]
(c) Vehicle registrations must begin with two letters and be followed by one, two or three digits.
Valid letters and digits are shown in the syntax diagrams on page 4.
(i)
State an example of a valid vehicle registration.
…
… [1]
(ii)
Draw a syntax diagram for a vehicle registration.
[3]
Question text
4
Draw one line to connect each stage of compilation to its most appropriate description.
Stage of compilation
Description
minimising a program’s execution time and
memory requirement
Lexical analysis
converting an intermediate representation of
source code into an executable form
Syntax analysis
converting a sequence of characters into a
sequence of tokens
Code generation
directly executing instructions written in a
scripting language
Optimisation
using parsing algorithms to interpret the
meaning of a sequence of tokens
[4]
Question text
5
(a) Write the infix expression in Reverse Polish Notation (RPN).
a * b + b - d + 15
…
… [1]
(b) (i)
Write the RPN expression in infix form.
a b - c d + * a /
…
… [1]
(ii)
Evaluate your infix expression from part (b)(i) when a = 5, b = 10, c = 27 and d = 12.
…
… [1]
Question text
8
Virtual memory, paging and segmentation are used in memory management.
(a) Explain what is meant by virtual memory.
…
…
…
…
…
… [3]
(b) State one difference between paging and segmentation in the way memory is divided.
…
… [1]
Question text
2
Lexical analysis and syntax analysis are stages in the compilation of a program.
(a) Identify two other stages that take place during the compilation of a program.
1 …
…
2 …
…
[2]
(b) Outline the purpose of syntax analysis.
…
…
…
… [2]
Question text
9
(a) Explain the need for scheduling in process management.
…
…
…
…
…
… [3]
(b) Describe these scheduling routines and identify a benefit for each one.
Shortest job first …
…
…
…
Round robin …
…
…
…
First come first served …
…
…
…
[6]
Question text
5
Part of a program’s calculations uses the integer variables j, k, m, n and p.
j
=
3
k
=
2
m
=
10
n
=
(j + k)/(j - k)
p
=
m * (m - j * k)
(a) Write the Reverse Polish Notation (RPN) for the expression:
(j + k)/(j - k)
… [2]
(b) (i)
Show the changing contents of the stack as the value for p is calculated from its RPN
expression:
m m j k * - *
[4]
(ii)
Describe the main steps in the evaluation of this RPN expression using a stack.
…
…
…
…
…
…
…
… [4]
(c) State two other uses of a stack.
1 …
…
2 …
…
[2]
Question text
4
The following syntax diagrams show the syntax of:
•
a variable
•
an unsigned integer
•
a letter
•
a digit
•
an operator
•
an assignment statement.
variable
letter
unsigned integer
unsigned integer
digit
digit
letter
digit
X
1
Y
2
Z
3
operator
+
–
*
assignment
statement
=
variable
variable
operator
variable
(a) The following assignment statements are invalid. State the reason in each case.
X1 = Y2 – 12
Reason …
…
Z = Y12 + Z1
Reason …
…
[2]
(b) Complete the Backus-Naur Form (BNF) for the syntax diagrams shown.
<letter> has been completed for you.
<variable> ::= …
…
<unsigned_integer> ::= …
…
<letter> ::= X | Y | Z
<digit> ::= …
…
<operator> ::= …
…
<assignment_statement> ::= …
…
[5]
(c) The syntax of an assignment statement is changed to allow each of the variables on the
right-hand side of the ‘=’ symbol to be either a variable or an unsigned integer.
(i)
Draw a syntax diagram for the new syntax of the assignment statement.
[3]
(ii)
Write the Backus-Naur Form (BNF) for your syntax diagram.
…
…
…
… [3]
Question text
4
The following syntax diagrams for a particular programming language show the syntax of:
•
a digit
•
a capital letter
•
a character.
digit
capital letter
0
A
1
E
2
I
3
O
4
U
5
character
$
6
%
7
&
8
*
9
#
(a) Write the Backus-Naur Form (BNF) notation of the syntax diagram for character.
…
…
… [2]
(b) A password must begin with a character and be followed by one or more digits or capital
letters.
(i)
State an example of a valid password.
… [1]
(ii)
A valid password is represented by the syntax diagram:
password
character
digit
capital letter
Write the BNF notation of the syntax diagram for password.
…
…
…
…
…
…
…
… [4]
Question text
3
(a) Draw one line to connect each Operating System (OS) term to the most appropriate
description about it.
OS term
Description
Using secondary storage to simulate
additional main memory
Multi-tasking
Managing the processes running on
the CPU
Paging
Managing the execution of many programs
that appear to run at the same time
Interrupt handling
Locating non-contiguous blocks of data and
relocating them
Scheduling
Transferring control to another routine when
a service is required
Virtual memory
Reading/writing same-size blocks of data
from/to secondary storage when required
[5]
(b) Explain how an interpreter executes a program without producing a complete translated
version of it.
…
…
…
…
…
…
…
… [4]
Question text
4
(a) (i)
Explain why Reverse Polish Notation (RPN) is used to carry out the evaluation of
expressions.
…
…
…
… [2]
(ii)
Identify, with reasons, a data structure that could be used to evaluate an expression
in RPN.
…
…
…
… [2]
(b) Write the infix expression in RPN.
(a – b) * (a + c) / 7
…
… [1]
(c) Write the RPN expression as an infix expression.
a b / 4 * a b + -
…
… [1]
(d) Evaluate the RPN expression:
a b + c d / /
where a = 17, b = 3, c = 48 and d = 12.
Show your working.
…
…
…
… [2]