0 ratings0% found this document useful (0 votes) 863 views16 pagesHKDSE ICT 2023 Paper 2D (E)
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content,
claim it here.
Available Formats
Download as PDF or read online on Scribd
¢
2023-DSE
IcT
PAPER 2D
HONG KONG EXAMINATIONS AND ASSESSMENT AUTHORITY
HONG KONG DIPLOMA OF SECONDARY EDUCATION EXAMINATION 2023
INFORMATION AND COMMUNICATION TECHNOLOGY
PAPER 2D
Software Development
Question-Answer Book
14:15 am— 12:45 pm (1 hour 30 minutes)
This paper must be answered in English
INSTRUCTIONS
(1) After the announcement of the start of the
examination, you should first write your Candidate
Number in the space provided on Page 1 and stick
barcode labels in the spaces provided on Pages 1, 3,5
and 7.
(2) Answer THREE out of four questions. Write your
answers in the spaces provided in this Question-
‘Answer book. Do not write in the margins. Answers
written in the margins will not be marked,
(3) Supplementary answer sheets will be supplied on
request. Write your candidate number, mark the
‘question number box and stick a barcode label on each
sheet, and fasten them with string INSIDE this book.
(4) No extra time will be given to candidates for sticking on
the barcode labels or filing in the question number
boxes after the “Time is up’ announcement.
OF BSRRF KE RG Fis
Hong Kong Examinations and Assessment Authority
All Rights Reserved 2023
Please stick the barcode label here.
Candidate Number [ |
*AZ2Z00E02D*Answers writen in the margins will not be marked.
Answer THREE questions only.
1. Evaplans to write a burger cooking game. She uses a queue A. to store the ingredients, A is implemented
by an array L. She designs subprograms with global variables, as shown below:
Global variable | Description
L ‘An array for storing the elements in A with indices from 1 10 5
c ‘A variable for storing the number of elements in_&
Subprogram | Description
enq(A, K)__| Inserts an element « in A if A isnot full
deq (A) Removes and returns an element in A if Ais not empty
(@) Suppose that © = 0. After sequentially executing eng (A, Fish) and enq(A, Onion),
c= 2 and
i E 2 3 a 5
Tia) Fish Onion
enq(A, K) outputsamessage ‘Full! * when A is full. Complete the pseudocode for eng below.
eng(A, K)
if then
output Full!"
else
Lt 1¢K
céec#i
(2 marks)
(b) (Suppose that C = 3 and
i i 2 El a 5
L{i]_[ Onion Tomato Bacon
Then, after executing deq (A),
c= 2 and
i i Zi 3 a 3
Lia) | Tomato Bacon
Fill in the content of 1 after further sequentially executing deq(A), eng(A, Cheese),
ena(A, Beef) and deq(A)
i i z 3 a 5
Lt)
@marks)
‘Answers written in the margins will not be marked.
‘Answers writen in the margins will not be marked.
2023-DSE-ICT 2D-2 2Please stick the barcode label here.
Gi) Complete the pseudocode for deq below.
deq(a)
if C = 0 then
output "Empty! *
else
3€1
tmp © L{1)
while j < C do
je gen
return tmp
(2 marks)
In the game, Eva uses a stack Sto represent a burger. She writes cook(A) using the following
subprograms where queue 2. stores all the ingredients of the burger.
‘Subprogram Description
push(S, K) | Inserts an element & in S as its top element
ELip (8) Reverses the order of all elements in_$
In the following example, after executing £1ip (S), the order of ll elements in S_is reversed,
Answers written in the margins will not be marked,
“Answers written in the margins will not be marked.
Fish onion
Bread > Beet
Beef | flip(s) | Bread
Onion Fish
5 s
Answers written in the margins will not be marked.
2023-DSE-ICT2D-3 3Answers written in the margins will not be marked,
‘Suppose that A. stores all the ingredients ofa specific burger. Eva writes cook(A) to cook the ingredients
in A. Suppose that Sis initially empty.
cook (A)
while A is not empty do
push(S, deqia))
flip(S)
(©) (Suppose that the content of 1 is:
z FE z 3 7 5
Tia) Beef Onion ‘Bread Bread
Fill in the content of S below, after executing cook (A).
8
(2 marks)
i) Suppose that the content of $ after executing cook (A) is:
Bread
Tomato
Lettuce
Beef
Bread
s
Fill in the initial content of 1. below.
z T Zz z 7 3
Lia]
1 L
(2 marks)
‘Answers written in the margins will not be marked.
“Answers written in the margins will not be marked.
2023-DSE-ICT 2D-4 43
z
2
E
Answers written in the margins
Please stick the barcode label here.
‘Another queue Bis implemented by an array R.
(@) @_ Suppose that the initial contents of $ and & are
enq(B, pop(S)) and eng(B, pop(S))
wanroon | [3 rn =]
tomaco | [at |
3
pop (S)_ is asubprogram that removes and returns the op element ofS.
Fill in the contents of S and R after sequentially executing enq(B, pop(S)),
a
fF
z
$
g
Z Z 2 3 a 3 ®
RU) E
2
§
€
$ 5
é
2 marks) | §
(ii) Complete the pseudocode for £1ip(S) below. <
s1ip(s)
while § is not empty do
ena( )
while do
push( )
(GB marks)
Answers writen in the margins will not be marked.
2023-DSE-ICT 2D-5 5Answers written in the margins will not be marked.
2. There are 30 booths in a food fair. Mary designs a floor plan with 6 rows and 5 columns. She uses an array
[4,3] to store the booth number of the booth in row i, column j.
Row i
1 2 3 4 5
Column 5
Mary virites a subprogram assign that assigns booth numbers to F, as shown below:
assignl
for i from 1 to 6 do
for j from 1 to 5 do
Fli, 4] € S*(i-1) + 5
(@) (i) Write down the booth number stored in F[5, 4]
mark)
(ii) Write down the indices ofthe clement in. F that stores booth number 17 2
:
FL p 1 2
(mary |S
Mary modifies assign1 to assign2 to reassign the booth numbers in the floor plan, as shown below: | §
z
2
‘
6 (aon 2s ze eT ze 8
5 [pan 22 23 24 25, 2
ee
Rows 3 [aa | aa | as | aa [as
2 | a eae | Ne
1 [ase acne se [ae
1 2 3 4 5
Column §
‘Answers written in the margins will not be marked.
2023-DSE-ICT 2D-6 6Answers written in the margins will not be marked.
Please stick the barcode label here.
(b) (Complete the pseudocode for assign? below.
assign2
for i from 1 to 6 do
for j from 1 to 5 do
if then
FUL, 4] € 5*(i-1)49
else
FL, 31 €
(3 marks)
(i) Mary writes a subprogram £indRow (num) that retums the row number of the booth with the
booth number num. For example, findRow(30) retums 6. Write the pseudocode for
findRow (num).
[Einatow mum)
(@ marks)
‘There are 10 vegetarian booths in the food fair and the
‘order, as shown below:
sooth numbers are stored in an array P in ascending
z fan m2 |S [ad 5 at]
By [+ 7 ase ae fe]
Mary writes a subprogram isVeg (num) thatretums TRUE if num isin P, EALSE otherwise.
Gi
“Answers written in the margins will nat be marked,
i) Complete the pseudocode for isVeg (num) below.
isVeg (num)
left € 1
right € 10
m € integral part of (left + right) /2
if P{m] = num then
return TRUE
else if Pim] < num then
Po
|
else
return FALSE
(B marks)
Answers written in the margins will nat be marked.
2023-DSE-ICT 2-7 7 (Goontothe nexipage >Answers written in the margins will not be marked.
(©) Mary considers using a low level language and a linker to develop the subprograms.
(8) Give an advantage of using low level language for software development.
(mark)
Describe the major function of a linker in the execution of a program.
(marks)
(@ Mary compares phased conversion and direct cutover conversion for system conversion. Give an
advantage of each kind of conversion.
Phased conversio
Direct cutover conversion:
@ marks)
“Answers written in the margins
‘Answers written in the margins will not be marked.
2023-DSE-ICT 2D-8 8Answers written in the margins will not be marked.
3 eter works on a project to redevelop a computer system using the Waterfall model with five phases.
(A) System implementation
(B) System conversion
(©) System analys
(D) System maintenance
(E) System design
(@) (i) Fill in the phases in the Waterfall model below.
ry
ry
“7
marks)
(Gi) What does Peter do inthe system maintenance phase?
The Gantt chart of the project is shown below.
fask four :
“Task five
(b) (@ What i the critical path of the project?
(i) Suppose that Task three finally needs 4 weeks to complete. What is the minimum number of weeks
required to complete the project?
(mark)
3
i
“Answers written in the margins will
(2 marks)
‘Answers wren nthe margins wil ot be marked
2oaypsp.icr 20-9 9Answers written in the margins will not be marked.
Peter develops a program with the following subprograms to sort integers in an array A in ascending order.
All integers in A. are distinct.
Subprogram Description ]
‘findmin(s, e) | Retum the index of the minimum valuein As], Als+1),.., Alel
where s < e.
Findmax(s, e) | Retum the index of the maximum valuein Als}, Afsti],.., Alel
where's < e.
swap ley yi Swap the values of A(x] and Aly)
‘Suppose that the initial content of A contains 7 integers:
i i z z q 5 @ 7
Ala] i9_|_28 ir [433 3 16_| 23
findmin(1, 4) retums 3 and findmax(3, 5) retums 4,
(©) (@_ Whatis the retur value of findnax (5, 7)?
mark)
il) Complete the pseudocode for findmax(s, e) below.
findmax(s, @)
tmp €
for k from s+1 to e do
if ALK) then
tmp €
return tmp
(G marks)
Answers written in the margins will not be marked.
2023-DSE-ICT 2D-10 10
‘Answers written in the margins will not be marked.Answers written in the margins will not be marked.
Peter tries to write the pseudocode for a subprogram sub1 for sorting.
subl
for j from 1 to 3 do
a € findmin(j, 8 - 3)
b € findmax(j, 8 - 5)
swap (3, a)
swap(B - 3, b)
(@) (Suppose that the initial content of A is:
i T z 3 a
SE ay a a a3 3 lee ewag
Fill in the content of A after the first pass and second pass of the loop in. sub1.
‘After the first pass
i L z 3 a 5 é 7
Ati]
‘After the second pass,
i I z 3 a 3 é 7
Ati]
(2 marks)
Gi) With the vatue in A(61 after the second pass, Peter understands that an incorrect sorting result is
obtained. To correct the algorithm, he modifies sub1 to sub2. Complete the pseudocode for
sub2 below.
sub2
for j from 1 to 3 do
a € findmin(j, 8 - 5)
b € finamax(j, 8 - 3)
swap(j, a)
swap(8 - j, b)
(3 marks)
Answers written in the margins will not be marked,
2o2s-pse-1cr 2-11 in
“Answers written in the margins will not be marked.Answers writen in the margins will not be marked.
4 ‘A map is represented by NxN cells. John works in a food delivery company. He uses an array MAP to
store the number of restaurants in each cell. The following example shows MAP. with
fl
‘
:
i 1
:
2
| ES
:
MAP
John writes a subprogram sum(i, j, K) that returns the sum of the numbers in KxK cells where
MAP{i, }) isthe top left cell For example, sun(i, 4, 2) retums 19+2+8421 = 50 where
MAP(1, 4) is the top left cell.
(2) (i) Whatis the return value of sum(1, 4, 3)?
(mark)
Gi) Whatare p and q sothat sum(p, q, 2) returns the maximum value among all the 22
cells?
(mark)
“Answers written in the margins will nat be marked.
‘Answers writen in the margins will not be marked.
2023-DSE-ICT 2D-12 12Answers written in the margins will not be marked,
@ For N = 6 and K = 2,
MAP.
The value of 2{2, 2] is the return value of sum (x,
Gi) For N = 6 and K = 3,
j
1203 4 5 6
1 fefeae Pelz yo
2 [olf aa fan) e fry 2 1
3 | ast[seufeye [eae |oa|
‘ 4 o 6 3 5 6 3 *
sfolofofole ls 2
es RCM ROM RON wep aa
MAP.
2oomout (K)
for i from 1 to N/K do
for j from 1 to N/K do
(b) John writes a subprogram Zoomout (K) that merges K*K cells into 1 cell by calculating the sum of |
the numbers in the Kx cells for MAP and storing the calculated sums in an array 2.
3, 2). Whatis x?
The value of Z[2, 2] istheretum value of sum(4, s, 3).Whatis s?
(mark)
i
1 2
148 58
2
(mark)
(ii) Suppose that Nv is divisible by K. Complete the pseudocode for Zoomout (&)
21d, 31 © sum
f fe
(2 marks)
Answers written in the margins will not be marked,
2023-DSE-ICT 2D-13,
13
‘Answers written in the margins will not be marked.will not be marked.
(©) Below are two subprograms and MAP with N= 6 and K = 2
2 [af ee [ar |e farq.
MAP.
funcl (i, 3)
tmp € 0
for p from i to itl do
for q from} to j+1 do
if MAP(p, q) > tmp then
tmp € MAP[p, a]
return tmp
func
tmp € 0
for i from 1 to 3 do
for j from 1 to 3 do
if Z[i, j] >= tmp then
if funcl(i*2-1, 3*2-1) > tmp then
tmp € funcl(i*2-1, j*2-1)
return tmp
() Whatis the return value of func (3, 1)?
(mark
(ii) Whats the return value of func2?
mark)
(iii) What is the purpose of func2?
(mark)
(iv) In £unc2, what will happen if the fourth statement ‘if Z[4, 3] >= tmp then*is removed?
mary
Answers written in the margins will not be marked.
2023-DSE-ICT 2D-14 14
‘Answers written in the margins will not be marked.Answers written in the margins will not be marked.
(@) John insists on using a compiler instead of an interpreter to write programs. Give a reason to support his
decision,
(mark)
(©) Some programming languages provide libraries to develop programs. Give two advantages of using
libraries.
‘(2 marks)
(John uses Java, which is an object-oriented language, to develop programs. Give two advantages of
‘object-oriented languages over procedural languages.
(@ marks)
END OF PAPER
“Answers written in the margins will not be marked.
Answers written in the margins will not be marked.
2021-DSEACT 2D-15 15Do not write on this page.
Answers written on this page will not be marked.
2023-DSE-ICT 2D-16 16