0% found this document useful (0 votes)
221 views17 pages

2021 HKACE Mock ICT 2D Eng Final 20201223

The document is a mock exam paper for an ICT exam. It contains 4 questions related to software development. Question 1 has parts about waterfall model, types of testing, benefits of programming languages, and RAD model. Question 2 is about finding the k-th largest element in an array. It involves sorting an array and defining subprograms. Question 3 and 4 are not shown.

Uploaded by

GL Mak
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
221 views17 pages

2021 HKACE Mock ICT 2D Eng Final 20201223

The document is a mock exam paper for an ICT exam. It contains 4 questions related to software development. Question 1 has parts about waterfall model, types of testing, benefits of programming languages, and RAD model. Question 2 is about finding the k-th largest element in an array. It involves sorting an array and defining subprograms. Question 3 and 4 are not shown.

Uploaded by

GL Mak
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 17

Please stick the label here.

THE HONG KONG ASSOCIATION FOR COMPUTER EDUCATION

INFORMATION AND COMMUNICATION TECHNOLOGY

MOCK EXAMINATION 2021 Candidate Number

PAPER 2D
Software Development

Time Allowed: 11:15 am – 12:45 am


(1 hour 30 minutes)
This paper must be answered in English. Marker’s Use Only

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.

(4) Supplementary answer sheets will be provided on


request. Write your candidate number and
question number on each sheet.

(5) No extra time will be given to candidates for filling


in candidate number and question number after
the ‘Time is up’ announcement.

© 香港電腦教育學會 保留版權
THE HONG KONG ASSOCIATION FOR COMPUTER EDUCATION
All Rights Reserved 2021

HKACE-ICT MOCK EXAM 2021-2D 1


Choose 3 out of 4 questions to answer.

1. Mary is a system analyst and she works for a new self-checkout system in a supermarket.

(a) She plans to use waterfall model to develop the system.

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:

Test case Details


The supermarket manager checks for the functionality of the whole system according to
1
the requirement.
2 Testing whether the barcode can be scanned for obtaining the product ID.

3 Testing the integration of the checkout system with the stock system.

What types of test are they?

Test case 1: _______________________________________________________________________

Test case 2: _______________________________________________________________________

Test case 3: _______________________________________________________________________


(3 marks)
(iii) High-level programming language and assembly language can be adopted for developing the system.
Suggest one benefit for each of the languages.
___________________________________________________________________________________

___________________________________________________________________________________

___________________________________________________________________________________

(2 marks)
(iv) Tom suggests using RAD instead of waterfall model to develop the system. State one reason to support
him.
___________________________________________________________________________________

___________________________________________________________________________________

(1 mark)

HKACE-ICT MOCK EXAM 2021-2D 2


(b) During the Design phase, a Data Flow Diagram (DFD) is used to illustrate the design of the whole system in the
supermarket.

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)

(i) Fill in the blanks to complete the Data Flow Diagram.

(A) _____________________________ (B) _____________________________

(C) _____________________________ (D) _____________________________

(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)

HKACE-ICT MOCK EXAM 2021-2D 3


2. John wants to write a program to find the k-th largest element in an array with N elements with index 0 to N-1.

(a) The following is an array with N=7 elements.

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)

(b) John writes the following subprograms.

findKthValue1(A, k) Return the k-th largest element in array A

copyArray(A, T) Copy the elements from array A to array T

swap(x, y) Swap the contents of variable x and y


(i) Write the pseudocode of swap(x, y) by using an extra variable z.
(You may assume x and y are passed by reference.)

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)

HKACE-ICT MOCK EXAM 2021-2D 4


(iii) Complete the following subprogram findKthValue1(A, k).

Subprogram findKthValue1(A, k)

Line 1: copyArray(A, T)

Line 2: for i from 0 to N-2 do

Line 3: for j from 0 to N-i-1 do

Line 4: if T[j] > T[j+1] then

Line 5: swap(T[j], T[j+1])

Line 6: return (2 marks)

(iv) Why John uses the subprogram copyArray(A, T) at Line 1? Explain briefly.

(1 mark)

HKACE-ICT MOCK EXAM 2021-2D 5


(c) John rewrites the algorithm and defines a new subprogram.

findKthValue2(A, k) Return the k-th largest element in array A

(i) Complete the following subprogram findKthValue2(A, k).

Subprogram findKthValue2(A, k)

Line 1: copyArray(A, T)

Line 2: for i from 0 to N-2 do

Line 3: maxIndex  i

Line 4: for j from i+1 to N-1 do

Line 5: if > T[maxIndex] then

Line 6: maxIndex 

Line 7:

Line 8: return T[k-1] (3 marks)

(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)

HKACE-ICT MOCK EXAM 2021-2D 6


3. Brackets are commonly used in mathematical expressions in different programming languages. A bracket is
considered to be any one of the following characters: ‘(’, ‘)’ . Two brackets are considered to be a matched pair
if the an opening bracket (i.e., ‘(’ ) occurs to the left of a closing bracket (i.e. ‘)’). Matched pair can be enclosed
or followed by other matched pair to form a sequence of brackets (e.g. “(()())” ). A sequence of brackets is
balanced if it contains no unmatched brackets. For example, “(()” is not balanced because it contains unmatched
brackets.

Sequence of brackets are stored in a character array SEQ of size n.

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 ( ) ( ) ( ( ) )

Return value: ______________________

0 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15

SEQ ( ( ( ) ( ) ( ) ) ) )

Return value: ______________________


(2 marks)

(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)

HKACE-ICT MOCK EXAM 2021-2D 7


Jayce writes another subprogram chkB2 to check whether a sequence of brackets is balanced of not. chkB2
makes use of stacks and the following subprograms are defined for stacks.
Subprograms Description
PUSH(S, k) Push the value stored in k into the stack S. If the stack is
full, run-time error will occur.
POP(S) Remove the value at the top of the stack S and return the
value. If the stack is empty, run-time error will occur.
isEmpty(S) Return True if the stack S is empty. False otherwise.
The pseudocode of chkB2 is
Subprogram chkB2
01 f  True
02 J  0
03 while J < n and f do
04 if SEQ[J] = '(' then
05 PUSH(S, SEQ[J])
06 else if SEQ[J] = ')' then
07 if isEmpty(S) then
08 f  False
09 else
10 t  POP(S)
11 if t ≠ '(' then
12 f  False
13 J  J + 1
14 return f

(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)

HKACE-ICT MOCK EXAM 2021-2D 8


(iii) Jayce finds that chkB2 cannot return the correct value in some cases. Give ONE example of these
cases.
0 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15

SEQ

Modify chkB2 so that it will return the correct value.


Subprogram chkB2
f  True
J  0
while J < n and f do
if SEQ[J] = '(' then
PUSH(S, SEQ[J])
else if SEQ[J] = ')' then
if isEmpty(S) then
f  False
else
t  POP(S)
if t ≠ '(' then
f  False
J  J + 1

return f and (3 marks)

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

The following shows some examples:

Sequence of brackets Balanced?


[[]] Yes
{[()]} Yes
({}[]) Yes
{(]} No
{{} No
}{ No
([)] No

HKACE-ICT MOCK EXAM 2021-2D 9


(c) The following shows the pseudocode of subprogram chkB3. Complete the subprogram.

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

if not isEmpty(S) then


f  False

return f

(6 marks)

HKACE-ICT MOCK EXAM 2021-2D 10


4. Laser cutting is a technology that makes use of a laser beam to slice materials. Laser cutting is done by directing the high-
power laser onto a material (Fig 4.1). A driver program with a control system is used to control the movement of the laser
head and power of the laser beam. Different powers of laser-beam are used to serve different purposes. A low power laser
can burn a mark on the material. A high power laser can slice it.

(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

LaserOn() Turn on the laser beam.

LaserOff() Turn off the laser beam.

MoveLH(x,y) Move the laser head to the position (x,y)

Variable Description

i, j Integer variables for iterations

x, y The x-coordinate and y-coordinate of a point

HKACE-ICT MOCK EXAM 2021-2D 11


(a) A subprogram DrawSquare1(x, y, length) is used to draw a filled square with the bottom left point at
(x,y) and the length of the square is length.
Complete the pseudo-code of DrawSquare1(x, y, length)

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)

HKACE-ICT MOCK EXAM 2021-2D 12


The laser head moves in a zigzag pattern in cutting.

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.

HKACE-ICT MOCK EXAM 2021-2D 13


Write down the content in Image[] for each of the following patterns. Array elements with "0" can be omitted.
(i) Image file:

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

(ii) Image file:

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)

HKACE-ICT MOCK EXAM 2021-2D 14


More variables in the control system of the laser cutter are given:

Variable Description

width, height Global variables that represent the width and height of the pattern to be
cut.

Pattern[i,j] A global integer array of the cutting pattern in 2-dimension format.

Image[i] A global integer array of the cutting pattern in a linear format.

current An integer variable to store the current cutting sequence number.

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[].

Complete the pseudo-code of mapping().

Mapping () {

for j from 0 to ___________ do

for i from 0 to ____________ do

____________________________  Pattern [i,j]


}

(2 marks)

HKACE-ICT MOCK EXAM 2021-2D 15


(e) A subprogram findNextPt(current, index)is used to find the next point to be cut in Image[].
Image[index] is the current cutting point. The integer variable current stores the current cutting sequence
number.

(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)

HKACE-ICT MOCK EXAM 2021-2D 16


(ii) Chris uses the laser cutter to cut the following pattern:

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

HKACE-ICT MOCK EXAM 2021-2D 17

You might also like

pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy