You are on page 1of 5

THE HONG KONG ASSOCIATION FOR COMPUTER EDUCATION

INFORMATION AND COMMUNICATION TECHNOLOGY


MOCK EXAMINATION 2020 – PAPER 2D Marking Scheme

1. (a) (i) x-axis: Time y-axis: Task 1


(ii) System Flowchart / Data Flow Diagram (DFD) / Structure Chart (any 2) 2

(b) (i)

ID Task Dependent on Duration (x50 Days)


1 Land Formation and Marine Works / 6
2 Airfield Facilities 3 5
3 Aprons Works 1 2
4 Runway Passenger Building 5 5
5 Automated People Mover System 1 4
6 Baggage Handling System 1 6
7 Airport Support Facilities 4 4
8 Public Facilities 4 3
1 mark for any 1 OR
2 marks for all correct

Duration( x50 days)


ID 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20
1
2
3
4
5
6
7
8
1 mark for task 3, 1 mark for task 5
1 mark for any 1 dependency OR 2 marks for all dependencies
(ii) 950 days 1

(c) (i)

2 F F T F F F F F
1

6 T F F F F F F F
1

(ii) S[i,j] = T 1
C[j]  C[j] + 1 2
1
2. (a) (i) Stack. Element can only be inserted at the top of the stack while element in linked list can be
inserted anywhere in the list. 1+1
OR
Queue. Element can only be enqueued at the end of the queue while element in linked list can be
inserted anywhere in the list. 1+1

(ii) It indicates the end of the linked list 1


(iii) any negative value except -2 1

(iv) D, C, G , F 2

(v) 6 1
(b) Address UNIT NEXT
0 START 1
1 A 3
2 E 4
3 F 7
4 B 5
5 D 8
6 C 2
7 G 6
8 H -2
All Correct 2 ORs

4 rows or above 1
(c) (i) The linked list can be transverse into two ways. 1

Address UNIT PREV NEXT


(ii)
0 START -1 4
1 A 2 5
2 E 7 1 1
3 F 4 7
4 B 0 3
5 D 1 8
6
7 G 3 2 1
8 H 5 -2

All Correct 1
(iii) NEXT[Z] 1
PREV[Z] 1

2
3. (a) (i)

After the first pass


1 2 3 4 5 6
item: 37 64 55 80 42 73
1
After the second pass
1 2 3 4 5 6
item: 37 55 64 80 42 73
1
(ii) 15 1
(iii) To sort the elements in the array in ascending order. 1
(iv) I agree. The first four elements are already in correct position. 1
(b) (i) item[j] > item[j+1] 1

swap(item[j], item[j+1]) 2

(c) (i) 6 1

(ii) 0 1

(d) True 1
1 to n-1 1
item[i] > item[i+1] 1

Valid  False 1
Valid 1

4. (a) True 1
data[j] = data[k] 1
Or 1

(b) (integral part of I / 3)*3 1


X + remainder of k/3 1

checkUniq(AR) 1

(c)
checkSol():
result  true;
for i  0 to 8 do
if not checkCol(i) or not checkRow(i) or not checkBox(i)
then
result  false
return result

1 Make use of the checkCol(), checkRow() and checkBox() subprograms


correctly.
1 Return boolean value
1 Consider all rows / Consider all columns / Consider all boxes

3
(d) Marking Scheme
Validation 1 mark
Converting the row and col from 1-9 to 0-8 1 mark
Correct logic on finding and outputting the hints 3 marks
All correct (including syntax) 1 mark
{C Version}
void findHints(int row, int col) {
int r[9];
int t;
int i, j;
for (t = 0; t < 9; t++) //Initialize the result array
r[t] = 1;
i = row - 1;
j = col - 1;
if (i > 8 || i < 0 || j > 8 || j < 0 || sol[i][j] != 0) { //Validation
printf("NA");
} else {
for (t = 0; t < 9; t++) {
/* Check Row */
if (sol[i][t] != 0)
r[sol[i][t]-1] = 0;
/* Check Col */
if (sol[t][j] != 0)
r[sol[t][j]-1] = 0;
/* Check Box */
if ( sol[ (i/3)*3+(t/3) ][ (j/3)*3+t%3 ] != 0)
r[ sol[ (i/3)*3+(t/3) ][ (j/3)*3+t%3 ] - 1 ] = 0;
}
for (t = 0; t < 9; t++) { //Output
if (r[t] == 1)
printf("%d", t+1);
}
}
}

{Pascal Version}
procedure findHints(row, col : integer);
var
t, i, j : integer;
r : array[0..8] of integer;
begin
for t := 0 to 8 do
r[t] := 1;
i := row - 1;
j := col - 1;
{ Validation }
if (i > 8) or (i < 0) or (j > 8) or (j < 0) or (sol[i, j] <> 0) then
writeln('NA')
else
begin
for t := 0 to 8 do
begin
{ Check Row }
if (sol[i, t] <> 0) then
r[sol[i, t]-1] := 0;
{ Check Col }
if (sol[t, j] <> 0) then
r[sol[t, j]-1] := 0;
{ Check Box }
if ( sol[(i div 3)*3+(t div 3),(j div 3)*3 + t mod 3] <> 0) then
r[ sol[(i div 3)*3+(t div 3),(j div 3)*3 + t mod 3]-1] := 0;
end;
{ Output }
for t := 0 to 8 do
if (r[t] = 1) then
Write(t+1);
end;
end;

4
{Java Version}
public static void findHints(int row, int col) {
int[] r = new int[9];
int t;
int i, j;
for (t = 0; t < 9; t++) //Initialize the result array
r[t] = 1;
i = row - 1;
j = col - 1;
if (i > 8 || i < 0 || j > 8 || j < 0 || sol[i][j] != 0) { //Validation
System.out.printf("NA");
} else {
for (t = 0; t < 9; t++) {
/* Check Row */
if (sol[i][t] != 0)
r[sol[i][t]-1] = 0;
/* Check Col */
if (sol[t][j] != 0)
r[sol[t][j]-1] = 0;
/* Check Box */
if ( sol[ (i/3)*3+(t/3) ][ (j/3)*3+t%3 ] != 0)
r[ sol[ (i/3)*3+(t/3) ][ (j/3)*3+t%3 ] - 1 ] = 0;
}
for (t = 0; t < 9; t++) { //Output
if (r[t] == 1)
System.out.printf("%d", t+1);
}
}
}

{Visual Basic Version}


Sub findHints(row as integer , col as integer)
Dim t, i, j as integer
Dim r(9) as integer

for t = 0 to 8
r(t) = 1
Next

i = row - 1
j = col - 1
'Validation
if (i > 8) or (i < 0) or (j > 8) or (j < 0) or (sol(i, j) <> 0) then
Console.Write("NA")
else
for t = 0 to 8
' Check Row
if (sol(i, t) <> 0) then
r(sol(i, t)-1) = 0
End if
' Check Col
if (sol(t, j) <> 0) then
r(sol(t, j)-1) = 0
End If
' Check Box
if ( sol( (i \ 3)*3+(t \ 3) , (j \ 3)*3 + (t mod 3) ) <> 0) then
r( sol( (i \ 3)*3+(t \ 3) , (j \ 3)*3 + t mod 3 ) - 1 ) = 0
End If
Next
End If
' Output
for t = 0 to 8
if (r(t) = 1) then
Console.Write(t+1)
End if
Next

end Sub

You might also like