2021 HKACE Mock ICT 2D Eng Final 20201223
2021 HKACE Mock ICT 2D Eng Final 20201223
PAPER 2D
Software Development
No. Marks
INSTRUCTIONS
(1) After the announcement of the start of the
1
examination, you should stick the label in the
2
space provided on
Page 1.
3
(2) Choose 3 out of 4 questions to answer.
4
(3) Write your answers in the spaces provided in this
Total
Question-Answer Book. Do not write in the
margins.
© 香港電腦教育學會 保留版權
THE HONG KONG ASSOCIATION FOR COMPUTER EDUCATION
All Rights Reserved 2021
1. Mary is a system analyst and she works for a new self-checkout system in a supermarket.
Analysis
Design
Implementation
Conversion &
Maintenance
Documentation
(i) State two phases that the users will not be involved.
___________________________________________________________________________________
(2 marks)
(ii) Mary plans to have three types of test during the Implementation phase as below:
3 Testing the integration of the checkout system with the stock system.
___________________________________________________________________________________
___________________________________________________________________________________
(2 marks)
(iv) Tom suggests using RAD instead of waterfall model to develop the system. State one reason to support
him.
___________________________________________________________________________________
___________________________________________________________________________________
(1 mark)
A customer can use the self-checkout system to buy the goods. He should first scan the barcode to input the product
ID and present the credit card for the payment. The self-checkout system will return a receipt to the customer. It
updates the checkout file with the checkout information and update the stock file with the updated stock
information.
The manager can update the stock files through the stock system by inputting the product ID and quantity.
(A)
(B) (C)
(D)
(E)
(E) _____________________________
(5 marks)
(ii) Other than Data Flow Diagram, suggest another chart that can be included in the Design phase.
___________________________________________________________________________________
(1 mark)
(iii) Mary wants to include this chart into the user manual. Do you agree? Explain briefly.
___________________________________________________________________________________
___________________________________________________________________________________
___________________________________________________________________________________
(1 mark)
Index 0 1 2 3 4 5 6
Value 72 23 67 85 14 2 57
By referring to the array above, what is the k-th largest element when k = 4? ______________ (1 mark)
Subprogram swap(x, y)
(2 marks)
(ii) Write the pseudocode of copyArray(A, T). You may declare any variable.
Subprogram copyArray(A, T)
(2 marks)
Subprogram findKthValue1(A, k)
Line 1: copyArray(A, T)
(iv) Why John uses the subprogram copyArray(A, T) at Line 1? Explain briefly.
(1 mark)
Subprogram findKthValue2(A, k)
Line 1: copyArray(A, T)
Line 3: maxIndex i
Line 6: maxIndex
Line 7:
(ii) Dry run the subprogram findKthValue2(A, k) and state the result of the array T after running the
subprogram:
Before:
Index 0 1 2 3 4 5 6
Value 72 23 67 85 14 2 57
After:
Index 0 1 2 3 4 5 6
Value
(2 marks)
(iii) The subprogram findKthValue2(A,k) in part (c) (i) can be optimized to reduce the runtime by
modifying one line of the pseudocode. State the line number and the necessary change below:
Line _____
(2 marks)
Jayce writes a subprogram chkB1 to check whether a sequence of brackets is balanced of not. The pseudocode of
chkB1 is:
Subprogram chkB1
01 ct 0
02 J 0
03 while J < n do
04 if SEQ[J] = '(' then
05 ct ct + 1
06 else if SEQ[J] = ')' then
07 ct ct – 1
08 J J + 1
09 if ct = 0 then
10 return True
11 else
12 return False
(a) Suppose n = 16.
(i) What are the return values of chkB1 for the following sequence of brackets stored in SEQ?
0 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15
SEQ ( ) ( ) ( ( ) )
0 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15
SEQ ( ( ( ) ( ) ( ) ) ) )
(ii) Jayce finds that chkB1 returns true in some cases that the sequence of brackets is not balanced.
Give ONE example of these cases.
0 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15
SEQ
(1 mark)
(b) (i) Suppose n = 16 and contents stored in SEQ is as shown below. What are the contents of the
stack S and the value of f when J become 5 at Line 03?
0 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15
SEQ ( ( ( ) ( ) ) )
bottom of stack
S
f = ___________________________
(2 marks)
(ii) Line 05 may generate a run-time error when the stack S is full. If n = 16, what should be the
minimum size of the stack S so that run-time error will never occur?
(1 mark)
SEQ
There are different types of backets used in mathematical expression and programming. Jayce creates another
subprogram chkB3 to check whether a sequence of brackets is balanced of not. A bracket is considered to be
any one of the following characters: ‘(’, ‘)’, ‘{’, ‘}’, ‘[’, or ‘]’. Two brackets are considered to be
a matched pair if the an opening bracket (i.e., ‘(’, ‘[’, or ‘{’) occurs to the left of a closing bracket
(i.e., ‘) ’, ‘]’, or ‘}’) of the exact same type. There are three types of matched pairs of
brackets: “[]”, “{}”, and “()”.
A matching pair of brackets is not balanced if the set of brackets it encloses are not matched. A sequence of
brackets is balanced if the following conditions are met:
• It contains no unmatched brackets.
• The set of brackets enclosed within a matched pair of brackets is also balanced
Subprogram chkB3
f True
J 0
while J < n and f do
C SEQ[J]
if C = '(' or C = '{' or C = '[' then
PUSH(S, SEQ[J])
else if C = ')' or C = '{' or C = '[' then
if isEmpty(S) then
f False
else
t POP(S)
if C == ')' then
if t != '(' then
f = False
if C == '}' then
if t != '{' then
f = False
if C == ']' then
if t != '[' then
f = False
J J + 1
return f
(6 marks)
(Fig 4.1)
The control system uses various subprograms and variables to carry out the laser cutting process.
Some of them are given below.
Subprogram Description
Variable Description
DrawSquare1(x,y,length) {
MoveLH(x,y)
(3 marks)
(b) Make use of subprogram in software development increases modularity. State two advantages of modular
programming.
(2 marks)
The pattern to be cut is stored in an image file. The driver program loads the file and stores it in an integer array
Pattern[i,j]. The numbers are cutting sequence number to denote the order to be cut. Continuous cutting points
are marked as the same sequence number. The number 0 is used to denote the point does not need to be cut.
i
4
3
2
1
0
j
0 1 2 3 4
(Fig 4.2)
(c) Before cutting the pattern, the driver program loads the image file and convert it to an array. The raw data in an
image file is in a linear format, which is good for data processing but cannot be used for laser-cutting easily. The
driver program reads the file and stores the data in an integer array Image[]. For the image file in Fig 4.2,
Image[] stores the data as shown in the following format:
(Fig 4.3)
The dimension of this pattern is 5 x 5. For every 5 elements in Image[], it will be mapped to one row of
Pattern[i,j]. For example, the first 5 elements of Image[], that is Image[0] to Image[4] are mapped to
the first row of Pattern [i,j], that is Pattern[0,0], Pattern[0,1], Pattern[0,2],
Pattern[0,3] and Pattern[0,4], as show in Fig 4.2.
Image[]:
Image[]
i 0 1 2 3 4 5 6 7 8 9
Image[]
i 10 11 12 13 14 15 16 17 18 19
Image[]
i 20 21 22 23 24
Image[]
i 0 1 2 3 4 5 6 7 8 9
Image[]
i 10 11 12 13 14 15 16 17 18 19
Image[]
i 20 21 22 23 24
(2 marks)
Variable Description
width, height Global variables that represent the width and height of the pattern to be
cut.
index An integer variable to store the index of image[] of the current cutting
point.
(d) A subprogram mapping() is used to convert the two-dimensional array Pattern[i,j] to the linear array
Image[].
Mapping () {
(2 marks)
(Fig 4.4)
In Fig.4.4, after cutting the last element of sequence 1, the program searches for and move to the first element of
sequence 2.
(i) Complete the pseudo-code of findNextPt(current, index) that return the index of the next point
to be cut by using linear search. Return -1 if the next point cannot be found.
findNextPt(current, index){
(4 marks)
He states that "Binary search is more efficient than linear search." for the subprogram findNextPt. Do
you agree with him in this case? Justify your answer.
(2 marks)
END OF PAPER