CSc9618 (A2) - Mock 3 - Paper 3
CSc9618 (A2) - Mock 3 - Paper 3
A2 Level
Exam Topic: Full Syllabus
Paper 3 Duration: 1.5 hours Total Marks: 70
...................................................................................................................................................
...................................................................................................................................................
(i) dog
is a valid <nounPhrase>
...........................................................................................................................................
...................................................................................................................................... [2]
...........................................................................................................................................
...........................................................................................................................................
...........................................................................................................................................
...................................................................................................................................... [2]
(iii) a cat slept the snake
is a valid <sentence>
...........................................................................................................................................
...........................................................................................................................................
...........................................................................................................................................
...........................................................................................................................................
...........................................................................................................................................
...................................................................................................................................... [4]
(iv) The adverbs quietly, quickly and slowly are to be included in the rules.
When an adverb is used in a sentence it always precedes the verb.
...........................................................................................................................................
...........................................................................................................................................
...........................................................................................................................................
...........................................................................................................................................
...................................................................................................................................... [3]
2 A number of music bands use a manager to organise their bookings.
Each manager will manage one or more bands.
Each band:
Data for bands and managers are to be organised and stored in a relational database.
State why the table MANAGER is not in First Normal Form (1NF).
...................................................................................................................................................
.............................................................................................................................................. [1]
MANAGER(ManagerName, Telephone)
The primary key for each table has not been shown.
Assume that the band names and manager names are unique.
(i) State the relationship that exists between BAND and MANAGER.
...................................................................................................................................... [1]
...........................................................................................................................................
...........................................................................................................................................
...................................................................................................................................... [2]
(c) The database is to be re-designed. It will store a date for each booking made.
A band does not have more than one booking on any one date.
Describe why the table BOOKING is not in Second Normal Form (2NF).
...................................................................................................................................................
...................................................................................................................................................
...................................................................................................................................................
.............................................................................................................................................. [2]
(i) Complete the table below to show the primary key and any foreign key(s) present in each
database table.
Foreign key(s)
Table Primary key
(if any)
..............................................................................
BAND BandName
..............................................................................
..............................................................................
MANAGER ManagerName
..............................................................................
..............................................................................
BOOKING
...................................................... ..............................................................................
..............................................................................
VENUE
...................................................... ..............................................................................
[4]
3 (a) Convert the following infix expressions into reverse Polish notation:
(i) x / (a + b)
...................................................................................................................................... [1]
(ii) p ^ 2 + (2 + q) / 3
Note: ^ denotes ‘to the power of’
...................................................................................................................................... [2]
3 a b + c + d + e - *
.............................................................................................................................................. [2]
4 The following syntax diagrams for a particular programming language show the syntax of:
a. a digit
b. a capital letter
c. a character.
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.
...................................................................................................................................................
...................................................................................................................................................
............................................................................................................................................. [3]
(b) A password must begin with a character and be followed by one or more digits or capital
letters.
..................................................................................................................................... [1]
character digit
capital letter
...........................................................................................................................................
...........................................................................................................................................
...........................................................................................................................................
...........................................................................................................................................
...........................................................................................................................................
...........................................................................................................................................
...........................................................................................................................................
..................................................................................................................................... [5]
11
Output
Layer
Input
Layer
Hidden Hidden
Layer 1 Hidden Layer 3
Layer 2
(i) State the reason for having multiple hidden layers in an artificial neural network.
...........................................................................................................................................
..................................................................................................................................... [1]
...........................................................................................................................................
...........................................................................................................................................
...........................................................................................................................................
...........................................................................................................................................
...........................................................................................................................................
...........................................................................................................................................
...........................................................................................................................................
...........................................................................................................................................
...........................................................................................................................................
..................................................................................................................................... [4]
(b) Find the shortest path between the Home and School nodes using the A* algorithm.
Show your working in the table provided.
14
h = 10 Home 9
g=1 4
A 5 C
3
7
B 6
2
6
D 6
3
7
F
1
2
3
E
3 5
School
Home 0 14 14
A 1 10 11
Final path
[5]
6 (a) State three essential features of recursion.
1 ................................................................................................................................................
...................................................................................................................................................
2 ................................................................................................................................................
...................................................................................................................................................
3 ................................................................................................................................................
...................................................................................................................................................
[3]
(b) Explain the reasons why a stack is a suitable Abstract Data Type (ADT) to implement
recursion.
...................................................................................................................................................
...................................................................................................................................................
...................................................................................................................................................
...................................................................................................................................................
...................................................................................................................................................
............................................................................................................................................. [3]
1 ................................................................................................................................................
2 ................................................................................................................................................
[2]
(d) The function StackFull() checks whether a stack is full.
The function uses the variable TopOfStack to represent the pointer to the most recent
position used on the stack, and the variable Max to represent the maximum size of the stack.
Assume TopOfStack and Max are global variables.
...................................................................................................................................................
...................................................................................................................................................
...................................................................................................................................................
...................................................................................................................................................
...................................................................................................................................................
...................................................................................................................................................
...................................................................................................................................................
...................................................................................................................................................
...................................................................................................................................................
ENDFUNCTION
[5]
(c) The reverse Polish expression RPNString consists of a sequence of characters. Each
character is either:
The following algorithm inputs RPNString and output the corresponding infix expression
InfixString.
INPUT RPNString
THEN
InfixString Temp
ENDIF
ENDWHILE
Complete the trace table for the input of the reverse Polish expression:
x y +
The first two iterations of the WHILE loop have been done for you.
x y + x
x
y y
x
[8]