HKDSE · Answers & Marking Scheme

2022 HKDSE Information and Communication Technology Answers & Marking Scheme

Thinka 2022 DSE-Style Mock — Information and Communication Technology

145 marks210 mins2022
An original Thinka practice paper modelled on the structure and difficulty of that year's HKDSE paper. Not affiliated with or reproduced from the HKEAA.

Paper 1 Section A (Multiple Choice)

Answer all forty questions. All questions carry equal marks. No marks will be deducted for wrong answers.
40 Question · 40 marks
Question 1 · Multiple Choice
1 marks
Which of the following 8-bit binary representations represents the decimal number -58 in two's complement representation?
  1. A.11000110
  2. B.11000101
  3. C.10111010
  4. D.10111011

Answer

A

Worked solution

To convert -58 to 8-bit two's complement:\n1. Find the binary representation of +58: \(58 = 32 + 16 + 8 + 2\), which is 00111010.\n2. Invert the bits (one's complement): 11000101.\n3. Add 1 to the result: 11000110.

Marking scheme

1 mark for the correct option A. No marks for incorrect choices.
Question 2 · Multiple Choice
1 marks
In a school database, there are two tables: STUDENT and CLASS.\nSTUDENT table: StudentID (Primary Key), Name, ClassID\nCLASS table: ClassID (Primary Key), ClassTeacher\nWhich of the following database operations will violate referential integrity?
  1. A.Inserting a new student record into STUDENT with an existing ClassID in the CLASS table.
  2. B.Updating a student's Name in the STUDENT table.
  3. C.Deleting a record from the CLASS table where the ClassID is currently assigned to some students in the STUDENT table.
  4. D.Deleting a record from the STUDENT table.

Answer

C

Worked solution

Referential integrity requires that a foreign key value must match an existing primary key value in the referenced table. If a record in the parent table (CLASS) is deleted while there are still matching records in the child table (STUDENT), the foreign key ClassID in STUDENT would refer to a non-existent primary key in CLASS, violating referential integrity.

Marking scheme

1 mark for correct option C.
Question 3 · Multiple Choice
1 marks
Which register stores the memory address of the next instruction to be fetched and executed by the CPU?
  1. A.Program Counter (PC)
  2. B.Instruction Register (IR)
  3. C.Memory Data Register (MDR)
  4. D.Accumulator (ACC)

Answer

A

Worked solution

The Program Counter (PC) is a dedicated CPU register that holds the memory address of the next instruction to be fetched and executed. Once the instruction is fetched, the PC is incremented to point to the next instruction.

Marking scheme

1 mark for correct option A.
Question 4 · Multiple Choice
1 marks
Which of the following statements about compilers and interpreters is correct?
  1. A.An interpreter translates the entire source code into machine code before execution, creating a standalone executable file.
  2. B.A compiler translates and executes the source code line by line, which makes debugging easier during program development.
  3. C.Compiled programs generally run faster than interpreted programs because translation is completed before execution.
  4. D.Interpreted programs do not require the interpreter to be present on the system during execution.

Answer

C

Worked solution

Compiled programs are already fully translated into machine code, allowing direct execution by the CPU at high speed. Interpreted programs must be translated line-by-line during runtime by an interpreter, which introduces overhead and requires the interpreter to be present.

Marking scheme

1 mark for correct option C.
Question 5 · Multiple Choice
1 marks
An IP address of a host is 192.168.10.45, and its subnet mask is 255.255.255.240. What is the network ID (subnet address) of the network to which this host belongs?
  1. A.192.168.10.0
  2. B.192.168.10.32
  3. C.192.168.10.40
  4. D.192.168.10.48

Answer

B

Worked solution

To find the network ID, perform a bitwise AND operation between the IP address and the subnet mask. For the fourth octet: IP = 45 (00101101 in binary), Mask = 240 (11110000 in binary). The bitwise AND is \(00101101 \text{ AND } 11110000 = 00100000\), which is 32 in decimal. Therefore, the network ID is 192.168.10.32.

Marking scheme

1 mark for correct option B.
Question 6 · Multiple Choice
1 marks
In public key cryptography, if Alice wants to send a confidential message to Bob, which key should Alice use to encrypt the message to ensure that only Bob can read it?
  1. A.Alice's private key
  2. B.Alice's public key
  3. C.Bob's private key
  4. D.Bob's public key

Answer

D

Worked solution

In public key cryptography, to ensure confidentiality, the sender (Alice) must encrypt the message using the recipient's (Bob's) public key. Only the recipient's private key (Bob's private key) can decrypt this message.

Marking scheme

1 mark for correct option D.
Question 7 · Multiple Choice
1 marks
Which of the following is an advantage of Radio Frequency Identification (RFID) technology over traditional barcodes?
  1. A.RFID tags require a direct line of sight between the reader and the tag to be scanned.
  2. B.Multiple RFID tags can be scanned simultaneously from a distance.
  3. C.RFID tags are much cheaper to manufacture and implement than barcode stickers.
  4. D.RFID tags cannot store read/write data and can only be used once.

Answer

B

Worked solution

RFID uses radio waves to transfer data, which does not require a direct line of sight. This allows readers to scan hundreds of RFID tags simultaneously and from a distance, whereas barcodes must be scanned individually with direct line of sight.

Marking scheme

1 mark for correct option B.
Question 8 · Multiple Choice
1 marks
Consider the following pseudocode:\n\n```\nSet count = 0\nFor i From 1 To 4\n For j From i To 4\n count = count + (i * j)\n Next j\nNext i\n```\n\nWhat is the final value of `count` after executing the pseudocode?
  1. A.50
  2. B.65
  3. C.70
  4. D.100

Answer

B

Worked solution

Let's trace the nested loops:\n- \(i = 1\): \(j\) runs from 1 to 4. \(\text{count} = 0 + (1\times1 + 1\times2 + 1\times3 + 1\times4) = 10\).\n- \(i = 2\): \(j\) runs from 2 to 4. \(\text{count} = 10 + (2\times2 + 2\times3 + 2\times4) = 10 + 18 = 28\).\n- \(i = 3\): \(j\) runs from 3 to 4. \(\text{count} = 28 + (3\times3 + 3\times4) = 28 + 21 = 49\).\n- \(i = 4\): \(j\) runs from 4 to 4. \(\text{count} = 49 + (4\times4) = 49 + 16 = 65\).\nThus, the final value of `count` is 65.

Marking scheme

1 mark for correct option B.
Question 9 · Multiple Choice
1 marks
A photographer publishes their photo under a 'CC BY-NC-ND' Creative Commons license. Which of the following acts is permitted under this license without obtaining additional permission?
  1. A.A school teacher prints the photo in a free school newsletter and gives credit to the photographer.
  2. B.A marketing firm uses the photo in a commercial advertisement with attribution.
  3. C.A graphic designer modifies the colors of the photo and publishes the edited version on a personal blog.
  4. D.A local business prints the photo on postcards and sells them to raise funds, attributing the photographer.

Answer

A

Worked solution

The license 'CC BY-NC-ND' stands for:\n- BY (Attribution): Credit must be given.\n- NC (Non-Commercial): Commercial use is prohibited.\n- ND (No Derivatives): Modifications are prohibited.\nOption A complies with all terms: it is non-commercial (free school newsletter), has no modifications, and attributes the photographer. Options B and D violate the NC clause, while Option C violates the ND clause.

Marking scheme

1 mark for correct option A.
Question 10 · Multiple Choice
1 marks
There is a database table `SALES` with the following columns: `SalespersonID`, `SaleAmount`, and `Region`.\nWhich of the following SQL statements finds the `Region` where the total sales amount exceeds 50000?
  1. A.`SELECT Region FROM SALES WHERE SUM(SaleAmount) > 50000 GROUP BY Region`
  2. B.`SELECT Region FROM SALES GROUP BY Region HAVING SUM(SaleAmount) > 50000`
  3. C.`SELECT Region FROM SALES GROUP BY Region WHERE SaleAmount > 50000`
  4. D.`SELECT Region, SUM(SaleAmount) FROM SALES WHERE SaleAmount > 50000`

Answer

B

Worked solution

In SQL, aggregate functions (such as `SUM`) cannot be used in a `WHERE` clause because the `WHERE` clause filters individual rows before grouping. To filter groups created by `GROUP BY` based on aggregate conditions, the `HAVING` clause must be used. Therefore, Option B is correct.

Marking scheme

1 mark for correct option B.
Question 11 · Multiple Choice
1 marks
In an 8-bit two's complement representation system, what is the result of adding the binary numbers representing the denary values \(-75\) and \(-85\)?
  1. A.The result is \(-160\), and no overflow occurs.
  2. B.The result is \(96\), and an overflow occurs.
  3. C.The result is \(-96\), and an overflow occurs.
  4. D.The result is \(-160\), and an overflow occurs.

Answer

B

Worked solution

In 8-bit two's complement, \(-75\) is represented as \(10110101_2\) and \(-85\) is represented as \(10101011_2\). Adding them gives: \(10110101_2 + 10101011_2 = 101100000_2\). Truncating to 8 bits gives \(01100000_2\), which is positive \(96_{10}\). Adding two negative numbers results in a positive number, which indicates that an arithmetic overflow has occurred.

Marking scheme

1 mark for the correct answer B. 0 marks for incorrect options.
Question 12 · Multiple Choice
1 marks
An IoT smart thermometer requires memory to store the following three items: (1) The bootloader program (startup code), (2) Real-time temperature logs collected over the last 24 hours, (3) The configured target temperature set by the user (which must persist even if the power is cut off). Which of the following combinations of memory types is the most suitable for storing each of these items respectively?
  1. A.(1) ROM, (2) RAM, (3) Flash Memory
  2. B.(1) RAM, (2) Flash Memory, (3) ROM
  3. C.(1) ROM, (2) Flash Memory, (3) RAM
  4. D.(1) Flash Memory, (2) ROM, (3) RAM

Answer

A

Worked solution

The bootloader (1) is non-volatile startup code, best stored in ROM. Real-time temperature logs (2) are frequently updated and do not need to persist permanently, so RAM is ideal. The user's configuration (3) needs to be non-volatile yet rewritable, making Flash Memory the most suitable.

Marking scheme

1 mark for the correct answer A. 0 marks for incorrect options.
Question 13 · Multiple Choice
1 marks
A computer user notices that when they open too many large applications simultaneously, the hard disk activity light blinks constantly, and the system response becomes extremely slow. This phenomenon is known as 'thrashing'. Which of the following is the primary cause of thrashing?
  1. A.The operating system is constantly swapping pages between RAM and virtual memory on the disk.
  2. B.The computer's hard disk has too many fragmented files, requiring the disk head to move constantly.
  3. C.The CPU cache is too small to store the current instructions, forcing the CPU to read directly from the RAM.
  4. D.The device drivers of the active applications are conflicting, causing repeated software interrupts.

Answer

A

Worked solution

Thrashing occurs when the virtual memory system is overloaded, causing the operating system to spend more time swapping memory pages between RAM and the hard disk (paging file) than executing actual applications.

Marking scheme

1 mark for the correct answer A. 0 marks for incorrect options.
Question 14 · Multiple Choice
1 marks
Consider two database tables: STUDENT (Student_ID, Name, Class, Club_ID) and CLUB (Club_ID, Club_Name, Teacher_In_Charge). 'Student_ID' and 'Club_ID' are the primary keys of STUDENT and CLUB respectively. 'Club_ID' in STUDENT is a foreign key referencing CLUB. Which of the following statements about referential integrity in this database is/are correct? (1) A new student record cannot be inserted with a Club_ID that does not exist in the CLUB table. (2) A club record cannot be deleted from the CLUB table if there are students currently registered with that Club_ID (assuming 'Restrict delete' is enforced). (3) A student's Club_ID can be set to NULL if joining a club is optional.
  1. A.(1) and (2) only
  2. B.(1) and (3) only
  3. C.(2) and (3) only
  4. D.(1), (2) and (3)

Answer

D

Worked solution

(1) is correct because referential integrity prevents foreign keys from referencing non-existent primary keys. (2) is correct because 'Restrict delete' prevents deletion of a primary record if there are child records referencing it. (3) is correct because if joining a club is optional, a NULL value is permitted in the foreign key field.

Marking scheme

1 mark for the correct answer D. 0 marks for incorrect options.
Question 15 · Multiple Choice
1 marks
A database table SALES has records with schema: SALES (Transaction_ID, Product_Category, Amount, Salesperson). The records are: ('T101', 'Electronics', 1500, 'Alice'), ('T102', 'Furniture', 800, 'Bob'), ('T103', 'Electronics', 400, 'Alice'), ('T104', 'Clothing', 200, 'Charlie'), ('T105', 'Furniture', 1200, 'Bob'), ('T106', 'Electronics', 150, 'Charlie'). What is the output of the query: SELECT Salesperson, SUM(Amount) FROM SALES GROUP BY Salesperson HAVING COUNT(Transaction_ID) >= 2 AND AVG(Amount) > 500;
  1. A.Alice 1900, Bob 2000
  2. B.Alice 1900, Bob 2000, Charlie 350
  3. C.Alice 1500, Bob 1200
  4. D.Bob 2000

Answer

A

Worked solution

Grouping by Salesperson: 'Alice' has 2 transactions with sum 1900 and average 950. 'Bob' has 2 transactions with sum 2000 and average 1000. 'Charlie' has 2 transactions with sum 350 and average 175. The HAVING clause filters out groups where average amount is not greater than 500, which excludes Charlie. Thus, only Alice and Bob are returned with their sums.

Marking scheme

1 mark for the correct answer A. 0 marks for incorrect options.
Question 16 · Multiple Choice
1 marks
Which of the following statements about MAC (Media Access Control) addresses and IP (Internet Protocol) addresses is correct?
  1. A.A MAC address operates at the Network layer of the OSI model, while an IP address operates at the Data Link layer.
  2. B.A router uses MAC addresses to forward packets across different subnets, while a switch uses IP addresses to forward frames within a local area network (LAN).
  3. C.An IP address is typically assigned by a manufacturer and cannot be changed, whereas a MAC address is assigned by a network administrator or DHCP server.
  4. D.When a packet is forwarded from one router to another across the Internet, the destination IP address in the packet header remains the same, but the destination MAC address in the frame header changes at each hop.

Answer

D

Worked solution

During routing across subnets, the logical IP addresses (source and destination) remain constant to ensure end-to-end delivery. However, the physical MAC addresses in the Layer 2 frame header are updated at each hop (router) to direct the frame to the next intermediate node on the physical link.

Marking scheme

1 mark for the correct answer D. 0 marks for incorrect options.
Question 17 · Multiple Choice
1 marks
In secure online transactions, asymmetric encryption is widely used. Which of the following correctly describes the main purpose of using a digital signature?
  1. A.To encrypt the transactional data so that eavesdroppers cannot read the details.
  2. B.To verify the authenticity and integrity of the message, and to ensure non-repudiation.
  3. C.To store and protect the private key of the sender securely on a certificate authority's server.
  4. D.To establish a direct physical connection between the sender and the receiver's computer.

Answer

B

Worked solution

A digital signature is created by hashing the message and encrypting the hash with the sender's private key. The recipient can decrypt it with the sender's public key to verify that the message indeed came from the sender (authenticity), has not been altered (integrity), and cannot be denied by the sender (non-repudiation).

Marking scheme

1 mark for the correct answer B. 0 marks for incorrect options.
Question 18 · Multiple Choice
1 marks
A school is developing a customized student portfolio system. Instead of purchasing physical servers, they decide to use a cloud service where they rent virtual machines with a pre-installed operating system and database management system, allowing their IT teachers to focus entirely on writing the system code and deploying the database. Which cloud service model are they using?
  1. A.Infrastructure as a Service (IaaS)
  2. B.Platform as a Service (PaaS)
  3. C.Software as a Service (SaaS)
  4. D.Network as a Service (NaaS)

Answer

B

Worked solution

Platform as a Service (PaaS) provides a computing platform, including operating system, programming language execution environment, database, and web server, which allows users to develop, run, and manage applications without the complexity of building and maintaining the infrastructure.

Marking scheme

1 mark for the correct answer B. 0 marks for incorrect options.
Question 19 · Multiple Choice
1 marks
Consider the following algorithm: A is an array of integers [3, 8, 2, 7, 5]; N = 5; X = A[0]; Y = A[0]; For i from 1 to N - 1 do: If A[i] > X then X = A[i] Else if A[i] < Y then Y = A[i] End If End For; Print X - Y. What is the printed output of this algorithm?
  1. A.3
  2. B.5
  3. C.6
  4. D.8

Answer

C

Worked solution

The algorithm finds the maximum value (X) and minimum value (Y) of the array. During iteration: i=1: A[1]=8 > 3 -> X=8. i=2: A[2]=2 < 3 -> Y=2. i=3: A[3]=7 (no change). i=4: A[4]=5 (no change). Thus, X=8, Y=2. Finally, X - Y = 8 - 2 = 6.

Marking scheme

1 mark for the correct answer C. 0 marks for incorrect options.
Question 20 · Multiple Choice
1 marks
Consider the following Python code to calculate the average of three test scores: score1 = 80; score2 = 90; score3 = 85; average = score1 + score2 + score3 / 3; print('The average is: ' + average). The programmer encounters two errors: (1) The calculated average is mathematically incorrect due to operator precedence, (2) The program crashes with a TypeError during runtime because of an attempt to concatenate a string and a float. Which of the following correctly classifies these two errors?
  1. A.(1) Logical error, (2) Runtime error
  2. B.(1) Syntax error, (2) Logical error
  3. C.(1) Runtime error, (2) Syntax error
  4. D.(1) Logical error, (2) Syntax error

Answer

A

Worked solution

Error (1) is a logical error because the program compiles and runs without crashing but produces incorrect logic (it calculates score1 + score2 + (score3/3) instead of (score1+score2+score3)/3). Error (2) causes the program to crash during execution due to unmatched types, which is classified as a runtime error.

Marking scheme

1 mark for the correct answer A. 0 marks for incorrect options.
Question 21 · MC
1 marks
What is the 8-bit two's complement representation of the decimal number \(-37\)?
  1. A.11011011
  2. B.11011010
  3. C.10100101
  4. D.11100101

Answer

a

Worked solution

To find the 8-bit two's complement of \(-37\): 1. Represent \(+37\) in 8-bit binary: \(00100101_2\). 2. Find the one's complement by inverting the bits: \(11011010_2\). 3. Add 1 to find the two's complement: \(11011010_2 + 1_2 = 11011011_2\).

Marking scheme

1 mark for the correct option. No marks for incorrect or multiple answers.
Question 22 · MC
1 marks
A database designer wants to ensure that a student record in the 'Student' table cannot be deleted if the student has already enrolled in any course in the 'Enrollment' table. Which integrity constraint should be applied?
  1. A.Entity integrity constraint
  2. B.Referential integrity constraint with CASCADE rule
  3. C.Referential integrity constraint with RESTRICT rule
  4. D.Domain integrity constraint with NOT NULL check

Answer

c

Worked solution

The referential integrity constraint ensures consistency between related tables. Under the RESTRICT rule (or NO ACTION), the system prevents the deletion of a record in the parent table ('Student') if there are corresponding matching records in the child table ('Enrollment').

Marking scheme

1 mark for the correct option. No marks for incorrect or multiple answers.
Question 23 · MC
1 marks
During the Fetch-Decode-Execute cycle, which register is used to store the address of the next instruction to be fetched from memory, and which register holds the instruction currently being decoded?
  1. A.Program Counter (PC) and Memory Data Register (MDR)
  2. B.Memory Address Register (MAR) and Instruction Register (IR)
  3. C.Program Counter (PC) and Instruction Register (IR)
  4. D.Accumulator (ACC) and Memory Data Register (MDR)

Answer

c

Worked solution

The Program Counter (PC) stores the address of the next instruction to be fetched. Once the instruction is fetched from memory, it is loaded into the Instruction Register (IR) where it is decoded and executed.

Marking scheme

1 mark for the correct option. No marks for incorrect or multiple answers.
Question 24 · MC
1 marks
A computer has an IP address of '192.168.10.45' and a subnet mask of '255.255.255.240'. Which of the following is the network address (subnet address) of this host?
  1. A.192.168.10.0
  2. B.192.168.10.32
  3. C.192.168.10.40
  4. D.192.168.10.48

Answer

b

Worked solution

The host part in the last octet is 45, which in binary is \(00101101_2\). The last octet of the subnet mask is 240, which is \(11110000_2\). Performing a bitwise AND operation: \(00101101_2 \text{ AND } 11110000_2 = 00100000_2\), which is 32 in decimal. Thus, the subnet address is '192.168.10.32'.

Marking scheme

1 mark for the correct option. No marks for incorrect or multiple answers.
Question 25 · MC
1 marks
To achieve both confidentiality and authenticity (non-repudiation) when Alice sends a message to Bob using public key cryptography, which of the following processes should Alice use?
  1. A.Encrypt the message with Alice's private key, and sign it with Bob's public key.
  2. B.Encrypt the message with Bob's public key, and sign it with Alice's private key.
  3. C.Encrypt the message with Alice's public key, and sign it with Bob's private key.
  4. D.Encrypt the message with Bob's private key, and sign it with Alice's public key.

Answer

b

Worked solution

To achieve confidentiality, Alice encrypts the message with Bob's public key so that only Bob can decrypt it with his private key. To achieve authenticity and non-repudiation, Alice signs the message with her private key, which anyone can verify using Alice's public key.

Marking scheme

1 mark for the correct option. No marks for incorrect or multiple answers.
Question 26 · MC
1 marks
Consider the following pseudocode which processes an array A of 6 elements: '[3, 8, 2, 7, 5, 10]':

N = 6
FOR i = 0 TO N-2
FOR j = i+1 TO N-1
IF A[i] < A[j] THEN
temp = A[i]
A[i] = A[j]
A[j] = temp
ENDIF
ENDFOR
ENDFOR

What is the content of array A immediately after the outer loop finishes its first iteration (where i = 0)?
  1. A.[8, 3, 2, 7, 5, 10]
  2. B.[10, 3, 2, 7, 5, 8]
  3. C.[10, 8, 7, 5, 3, 2]
  4. D.[3, 8, 2, 7, 5, 10]

Answer

b

Worked solution

When i = 0, the inner loop compares A[0] with A[j] for j from 1 to 5:
- j = 1: A[0] < A[1] (3 < 8) is true -> swap, A becomes [8, 3, 2, 7, 5, 10]
- j = 2: A[0] < A[2] (8 < 2) is false
- j = 3: A[0] < A[3] (8 < 7) is false
- j = 4: A[0] < A[4] (8 < 5) is false
- j = 5: A[0] < A[5] (8 < 10) is true -> swap, A becomes [10, 3, 2, 7, 5, 8].
Thus, at the end of i = 0, the array is [10, 3, 2, 7, 5, 8].

Marking scheme

1 mark for the correct option. No marks for incorrect or multiple answers.
Question 27 · MC
1 marks
A database table STUDENT has the attributes StudentID, Name, Class, Gender, and Score. Which of the following SQL statements correctly displays the Class and the number of female students for classes with more than 5 female students?
  1. A.SELECT Class, COUNT(*) FROM STUDENT WHERE Gender = 'F' GROUP BY Class HAVING COUNT(*) > 5;
  2. B.SELECT Class, COUNT(*) FROM STUDENT GROUP BY Class HAVING Gender = 'F' AND COUNT(*) > 5;
  3. C.SELECT Class, COUNT(*) FROM STUDENT WHERE Gender = 'F' AND COUNT(*) > 5 GROUP BY Class;
  4. D.SELECT Class, COUNT(*) FROM STUDENT GROUP BY Class WHERE Gender = 'F' HAVING COUNT(*) > 5;

Answer

a

Worked solution

Option (a) is correct. It filters female students first using WHERE, groups them by Class, and then uses HAVING to filter classes with more than 5 students. Option (b) fails because Gender is used in HAVING without being grouped. Option (c) fails because aggregate functions (COUNT) cannot be used in WHERE. Option (d) has incorrect SQL keyword ordering.

Marking scheme

1 mark for the correct option. No marks for incorrect or multiple answers.
Question 28 · MC
1 marks
An illustrator shares their digital artwork under a Creative Commons license. The terms of the license allow others to copy, distribute, and display the work, and also allow others to modify or build upon the work. However, any commercial use is forbidden, and any modified works must be shared under the same license terms. Which of the following Creative Commons licenses did the illustrator apply?
  1. A.CC BY-ND
  2. B.CC BY-NC-ND
  3. C.CC BY-NC-SA
  4. D.CC BY-SA

Answer

c

Worked solution

The restrictions are: attribution (BY, default in CC), non-commercial (NC), and share-alike (SA, modified works shared under same terms). Since modifying is allowed, ND (No Derivatives) is NOT applied. Therefore, the license is CC BY-NC-SA.

Marking scheme

1 mark for the correct option. No marks for incorrect or multiple answers.
Question 29 · MC
1 marks
Which of the following statements about Virtual Memory is/are correct?

(1) Virtual memory uses a portion of secondary storage (such as a hard disk or SSD) to simulate additional RAM.
(2) Increasing the size of virtual memory can speed up CPU instruction execution as effectively as increasing physical RAM.
(3) A "page fault" occurs when the requested memory page is not currently located in the physical RAM and needs to be fetched from secondary storage.
  1. A.(1) only
  2. B.(1) and (3) only
  3. C.(2) and (3) only
  4. D.(1), (2) and (3)

Answer

b

Worked solution

(1) is correct as virtual memory uses secondary storage to extend address space. (2) is incorrect because secondary storage is significantly slower than physical RAM; relying heavily on virtual memory causes 'thrashing' and slows down the system. (3) is correct by definition of a page fault.

Marking scheme

1 mark for the correct option. No marks for incorrect or multiple answers.
Question 30 · MC
1 marks
A web form requires users to enter a Hong Kong Identity Card (HKID) number. The system performs several validation checks on the input:
(1) Check if the input is not left blank.
(2) Check if the input format matches one or two uppercase letters, followed by six digits, and a single digit/letter in parentheses.
(3) Calculate and verify the check digit using a weighted formula based on the preceding characters.
Which of the following correctly identifies these validation checks?
  1. A.(1) Presence check, (2) Range check, (3) Type check
  2. B.(1) Presence check, (2) Format check, (3) Check digit validation
  3. C.(1) Type check, (2) Format check, (3) Range check
  4. D.(1) Range check, (2) Type check, (3) Check digit validation

Answer

b

Worked solution

(1) Checking if a mandatory field is filled is a presence check. (2) Checking if the characters follow a specific template is a format check. (3) Verifying the correctness of an embedded validation digit using a mathematical algorithm is a check digit validation.

Marking scheme

1 mark for the correct option. No marks for incorrect or multiple answers.
Question 31 · Multiple Choice
1 marks
If an 8-bit register uses 2's complement representation, what is the 8-bit binary result of the subtraction \(01001100_2 - 10110101_2\), and does overflow occur?
  1. A.\(10010111_2\), overflow occurs
  2. B.\(10010111_2\), overflow does not occur
  3. C.\(11001001_2\), overflow occurs
  4. D.\(11001001_2\), overflow does not occur

Answer

A

Worked solution

First, convert both numbers to decimal or compute in binary. \(A = 01001100_2 = 76_{10}\). \(B = 10110101_2\). Since MSB of \(B\) is 1, it is a negative number. Its magnitude is found by flipping the bits and adding 1: \(01001010 + 1 = 01001011_2 = 75_{10}\). Thus \(B = -75_{10}\). The subtraction is \(A - B = 76 - (-75) = 151_{10}\). The range of an 8-bit 2's complement system is \([-128, 127]\). Since 151 is outside this range, overflow occurs. Performing the subtraction in binary: \(01001100_2 - 10110101_2 = 01001100_2 + 01001011_2 = 10010111_2\). The result has a sign bit of 1, indicating a negative number, which conflicts with a positive result, confirming overflow.

Marking scheme

1 mark for the correct answer A.
Question 32 · Multiple Choice
1 marks
Which of the following statements about cache memory in a computer system are correct?
(1) It stores frequently used data and instructions to reduce the average time to access memory.
(2) It has a faster access speed than registers.
(3) It resides inside or very close to the CPU chip.
  1. A.(1) only
  2. B.(1) and (3) only
  3. C.(2) and (3) only
  4. D.(1), (2) and (3)

Answer

B

Worked solution

Statement (1) is correct as cache acts as a temporary buffer to speed up data access between CPU and RAM. Statement (2) is incorrect because registers are the fastest memory located directly inside the CPU core, which are faster than cache. Statement (3) is correct as cache memory is designed to be physically close to or integrated into the CPU to minimize latency.

Marking scheme

1 mark for the correct answer B.
Question 33 · Multiple Choice
1 marks
Consider two database tables: `STUDENT(StudentID, Name, ClassID)` and `CLASS(ClassID, ClassTeacher, RoomNo)`. `StudentID` and `ClassID` are the primary keys of the respective tables. `ClassID` in `STUDENT` is a foreign key referencing `CLASS`. Which of the following operations will be rejected by the DBMS in order to maintain referential integrity?
(1) Inserting a new record into `STUDENT` with a `ClassID` that does not exist in `CLASS`.
(2) Deleting a record from `CLASS` whose `ClassID` is currently assigned to some students in `STUDENT`.
(3) Deleting a record from `STUDENT`.
  1. A.(1) only
  2. B.(2) only
  3. C.(1) and (2) only
  4. D.(1), (2) and (3)

Answer

C

Worked solution

Operation (1) is rejected because the foreign key in `STUDENT` must reference an existing primary key in `CLASS`. Operation (2) is rejected because deleting a parent record that has associated child records would leave orphan records in `STUDENT`, violating referential integrity. Operation (3) is allowed because deleting a record from a child table does not violate any referential integrity constraints.

Marking scheme

1 mark for the correct answer C.
Question 34 · Multiple Choice
1 marks
A subnet of a school network has the IP address `192.168.10.32` with a subnet mask of `255.255.255.240`. Which of the following is/are valid IP address(es) for host computers on this subnet?
(1) `192.168.10.35`
(2) `192.168.10.45`
(3) `192.168.10.47`
  1. A.(1) only
  2. B.(1) and (2) only
  3. C.(2) and (3) only
  4. D.(1), (2) and (3)

Answer

B

Worked solution

The subnet mask is `255.255.255.240`. The last octet has 4 subnet bits and 4 host bits. With 4 host bits, there are \(2^4 = 16\) addresses per subnet. For the subnet starting at `192.168.10.32`:
- Subnet/Network Address: `192.168.10.32`
- First usable host address: `192.168.10.33`
- Last usable host address: `192.168.10.46`
- Broadcast Address: `192.168.10.47`
Therefore, `192.168.10.35` and `192.168.10.45` are valid host addresses. `192.168.10.47` is the broadcast address, which cannot be assigned to a host computer. Hence, (1) and (2) only.

Marking scheme

1 mark for the correct answer B.
Question 35 · Multiple Choice
1 marks
Alice wants to send an encrypted and digitally signed email to Bob. She wants to ensure confidentiality (only Bob can decrypt and read it) and authenticity (Bob can verify the email was sent by Alice). Which keys should Alice use to encrypt the email message and to create the digital signature respectively?
  1. A.Encrypt message: Bob's private key; Create signature: Alice's public key
  2. B.Encrypt message: Alice's private key; Create signature: Bob's public key
  3. C.Encrypt message: Bob's public key; Create signature: Alice's private key
  4. D.Encrypt message: Alice's public key; Create signature: Bob's private key

Answer

C

Worked solution

To achieve confidentiality, Alice must encrypt the message with the recipient's public key (Bob's public key), so that only the corresponding private key (Bob's private key) can decrypt it. To achieve authenticity, Alice must sign the message using her own private key (Alice's private key). Bob can then verify this signature using Alice's public key.

Marking scheme

1 mark for the correct answer C.
Question 36 · Multiple Choice
1 marks
Consider the following pseudocode algorithm:
```
A = 45
B = 12
COUNT = 0
While A >= B Do
A = A - B
COUNT = COUNT + 1
EndWhile
```
What are the values of `A` and `COUNT` after the execution of the algorithm?
  1. A.`A = 21`, `COUNT = 2`
  2. B.`A = 0`, `COUNT = 3`
  3. C.`A = 9`, `COUNT = 4`
  4. D.`A = 9`, `COUNT = 3`

Answer

D

Worked solution

Let's dry run the algorithm:
- Initial: `A = 45`, `B = 12`, `COUNT = 0`
- Loop 1: `A >= B` (45 >= 12 is True)
- `A = 45 - 12 = 33`
- `COUNT = 0 + 1 = 1`
- Loop 2: `A >= B` (33 >= 12 is True)
- `A = 33 - 12 = 21`
- `COUNT = 1 + 1 = 2`
- Loop 3: `A >= B` (21 >= 12 is True)
- `A = 21 - 12 = 9`
- `COUNT = 2 + 1 = 3`
- Loop 4: `A >= B` (9 >= 12 is False). The loop terminates.
- Final values: `A = 9`, `COUNT = 3`.

Marking scheme

1 mark for the correct answer D.
Question 37 · Multiple Choice
1 marks
A school registration system requires users to enter a student's date of birth in the format `DD/MM/YYYY`. Which of the following validation checks can be applied to verify the correctness of the input?
(1) Format check to ensure the input contains forward slashes at correct positions.
(2) Range check to ensure the month `MM` is between 1 and 12.
(3) Verification check by double entry of the date of birth.
  1. A.(1) and (3) only
  2. B.(2) and (3) only
  3. C.(1) and (2) only
  4. D.(1), (2) and (3)

Answer

C

Worked solution

Validation checks are automated procedures carried out by a computer to identify invalid data. (1) Format check and (2) Range check are validation techniques. (3) Double entry is a data verification method, which is used to check if data has been copied or entered accurately, but is not a system-automated validation rule on the input string format itself. Thus, (1) and (2) only.

Marking scheme

1 mark for the correct answer C.
Question 38 · Multiple Choice
1 marks
In an operating system, what is the main purpose of "paging" in virtual memory management?
  1. A.To compress data stored in the RAM to save system resources
  2. B.To automatically defragment the storage device to improve direct access speed
  3. C.To ensure that multiple active processes can write to the exact same physical memory address simultaneously without conflict
  4. D.To divide physical and virtual memory into fixed-size blocks to allow non-contiguous physical memory allocation to processes

Answer

D

Worked solution

Paging is a memory management scheme that eliminates the need for contiguous allocation of physical memory. It divides physical memory into fixed-size blocks (called page frames) and virtual memory into same-sized blocks (called pages), allowing the operating system to store processes in non-contiguous physical memory locations.

Marking scheme

1 mark for the correct answer D.
Question 39 · Multiple Choice
1 marks
A programmer wants to release their software under a Creative Commons license. They want to allow others to copy, distribute, and display the software, but only if they give the programmer proper credit, do not use it for commercial purposes, and do not make any derivative works (no modifications). Which combination of Creative Commons terms should the programmer choose?
  1. A.CC BY-NC-SA
  2. B.CC BY-NC-ND
  3. C.CC BY-SA-ND
  4. D.CC BY-NC

Answer

B

Worked solution

To require giving proper credit, the programmer needs 'Attribution' (BY). To restrict usage to non-commercial activities, the programmer needs 'Non-Commercial' (NC). To prevent modification/creation of derivative works, the programmer needs 'No Derivatives' (ND). Therefore, the correct combination is CC BY-NC-ND.

Marking scheme

1 mark for the correct answer B.
Question 40 · Multiple Choice
1 marks
Consider a database table `SALES(SalesID, ProductID, Region, Amount)`. Which SQL query can find the regions where the total sales amount exceeds 50,000?
  1. A.SELECT Region FROM SALES WHERE SUM(Amount) > 50000 GROUP BY Region
  2. B.SELECT Region FROM SALES GROUP BY Region HAVING SUM(Amount) > 50000
  3. C.SELECT Region FROM SALES WHERE Amount > 50000 GROUP BY Region
  4. D.SELECT Region FROM SALES GROUP BY Region WHERE SUM(Amount) > 50000

Answer

B

Worked solution

To calculate the total sales amount per region, we must group the records by `Region` using `GROUP BY Region`. To filter the groups based on an aggregate condition (sum of amount > 50000), we must use the `HAVING` clause because `WHERE` cannot be used with aggregate functions like `SUM()`. Therefore, Option B is correct.

Marking scheme

1 mark for the correct answer B.

Paper 1 Section B (Structured Questions)

Answer all five compulsory questions in this section.
5 Question · 60 marks
Question 1 · Compulsory Structured Case Study
12 marks
A digital temperature monitoring system in a vaccine cold room logs temperatures and security codes.

(a) The sensor records temperature in 8-bit two's complement representation.
(i) Express the binary representation 11110100 in decimal. (2 marks)
(ii) What is the range of integers (in decimal) that can be represented using 8-bit two's complement? (2 marks)

(b) The system logs security codes in hexadecimal format.
(i) Convert the denary number 213 into a 2-digit hexadecimal number. (2 marks)
(ii) State one reason why system administrators prefer hexadecimal representation over binary representation. (2 marks)

(c) When transmitting data, the system uses ASCII encoding with an even parity bit.
(i) The character 'A' has the ASCII value of 65 in denary. Write down the 8-bit byte (with the parity bit as the most significant bit) to transmit 'A'. (2 marks)
(ii) Explain a limitation of using a single parity bit for error detection. (2 marks)

Answer

(a)(i) -12 (a)(ii) -128 to 127 (b)(i) D5 (b)(ii) Hexadecimal is shorter, more readable, and reduces transcription errors compared to binary. (c)(i) 01000001 (c)(ii) It cannot detect errors if an even number of bits are corrupted.

Worked solution

(a) (i) 11110100 in 2's complement is negative. Invert bits: 00001011, add 1: 00001100, which is 12. Thus, -12.
(ii) Formula for range: \(-2^{n-1}\) to \(2^{n-1} - 1\). For 8 bits, this is \(-2^7\) to \(2^7 - 1\), which is -128 to 127.

(b) (i) 213 / 16 = 13 remainder 5. 13 in hex is D. Thus, D5.
(ii) Hexadecimal represents 4 bits with a single character, making it shorter and easier for humans to read, write, and debug than binary, while maintaining a simple direct conversion.

(c) (i) Denary 65 = Binary 1000001 (7-bit). Count of 1s is 2 (which is even). Therefore, the parity bit must be 0 to keep the total number of 1s even. 8-bit byte: 01000001.
(ii) A single parity bit can only detect an odd number of bit errors. If an even number of bits (e.g., 2 bits) change during transmission, the parity remains correct and the error goes undetected.

Marking scheme

(a)(i) 1 mark for correct magnitude (12), 1 mark for negative sign (-12).
(a)(ii) 1 mark for the lower limit (-128), 1 mark for the upper limit (127).
(b)(i) 1 mark for calculating division by 16, 1 mark for correct hex value (D5).
(b)(ii) 2 marks for a well-explained reason (e.g., readability, conciseness, reducing errors).
(c)(i) 1 mark for converting 65 to binary (1000001), 1 mark for prepending the correct even parity bit (0).
(c)(ii) 2 marks for explaining that an even number of errors cancel out the parity change and go undetected.
Question 2 · Compulsory Structured Case Study
12 marks
A school library database management system contains two tables: BOOKS and LOANS.

BOOKS (BookID, Title, Author, Category)
LOANS (LoanID, BookID, MemberID, LoanDate, ReturnDate)

(a) State the relationship between BOOKS and LOANS. Explain how this relationship is implemented in the schema. (2 marks)
(b) Explain the importance of referential integrity in this database using BookID as an example. (2 marks)
(c) Write an SQL query to retrieve the Title and Author of all books under the 'Science' category. (2 marks)
(d) Write an SQL query to find the BookID and the total number of loans for each book that has been borrowed more than 5 times. (3 marks)
(e) Explain why the Title of the book should not be stored in the LOANS table. (3 marks)

Answer

(a) One-to-many. It is implemented by including BookID (primary key of BOOKS) as a foreign key in LOANS. (b) It ensures that every BookID in LOANS must exist in BOOKS, preventing loans for non-existent books. (c) SELECT Title, Author FROM BOOKS WHERE Category = 'Science'; (d) SELECT BookID, COUNT(*) FROM LOANS GROUP BY BookID HAVING COUNT(*) > 5; (e) Storing Title in LOANS introduces data redundancy, leading to storage waste and update anomalies.

Worked solution

(a) The relationship is one-to-many (one book can be borrowed multiple times). It is implemented by placing the primary key of the BOOKS table (`BookID`) as a foreign key in the LOANS table.

(b) Referential integrity ensures consistency between related tables. Specifically, it prevents a user from inserting a record in LOANS with a `BookID` that does not exist in the BOOKS table, and prevents deleting a book from BOOKS if it has active borrowing records in LOANS.

(c) The SQL query selects fields from BOOKS filtered by Category:
`SELECT Title, Author FROM BOOKS WHERE Category = 'Science';`

(d) The SQL query groups by BookID and uses HAVING to filter aggregate results:
`SELECT BookID, COUNT(*) FROM LOANS GROUP BY BookID HAVING COUNT(*) > 5;`
(Accept `COUNT(LoanID)` or `COUNT(BookID)` instead of `COUNT(*)`).

(e) Storing `Title` in the LOANS table causes data redundancy because the title is already recorded in the BOOKS table. This results in waste of storage and can cause update anomalies (e.g., if a book's title is modified in BOOKS, it would also need to be manually updated in multiple records in LOANS to maintain consistency).

Marking scheme

(a) 1 mark for stating 'one-to-many', 1 mark for explaining foreign key linkage.
(b) 1 mark for explaining database consistency, 1 mark for applying it to the context of preventing invalid BookID in LOANS.
(c) 1 mark for correct SELECT and FROM clauses, 1 mark for correct WHERE clause.
(d) 1 mark for SELECT BookID, COUNT(*), 1 mark for GROUP BY BookID, 1 mark for HAVING COUNT(*) > 5.
(e) 1 mark for identifying data redundancy / storage waste, 2 marks for explaining update anomalies (inconsistent data when title changes).
Question 3 · Compulsory Structured Case Study
12 marks
Mr. Chan is setting up a local area network (LAN) for his new office.

(a) He is choosing network hardware to connect 15 computers.
(i) Explain why a network switch is preferred over a network hub in terms of network transmission performance. (2 marks)
(ii) Explain why a network switch is more secure than a network hub. (2 marks)

(b) The office router uses DHCP.
(i) State the full form of DHCP and describe its main function. (2 marks)
(ii) If a client computer fails to connect to the DHCP server, it might assign itself an APIPA address. Can this computer access the Internet? Explain your answer. (2 marks)

(c) Mr. Chan wants to protect his network from external threats.
(i) Distinguish between packet filtering and application-level gateway (proxy) firewalls. (2 marks)
(ii) Give an example of a rule that can be configured in a packet-filtering firewall to allow only web traffic (HTTP) to reach the internal web server. (2 marks)

Answer

(a)(i) A switch transmits packets only to the target device, reducing network collisions and boosting throughput, unlike a hub which broadcasts to all ports. (a)(ii) A hub broadcasts data to all ports, making it easy to sniff traffic. A switch isolates traffic to the destination port. (b)(i) Dynamic Host Configuration Protocol. It automatically assigns IP addresses and configurations to devices. (b)(ii) No. APIPA addresses are non-routable link-local addresses, meaning they only allow communication within the local subnet. (c)(i) Packet filtering looks only at IP/port headers, while application-level gateway inspects the actual packet payload and application protocols. (c)(ii) Allow incoming TCP packets only if the destination port is 80 (or 443) and directed to the web server's IP.

Worked solution

(a) (i) A switch establishes a direct connection between the sender and the receiver (unicast), whereas a hub broadcasts data packets to all connected ports. This reduces collisions and congestion, improving overall network bandwidth and performance.
(ii) Since a hub broadcasts all data, any device on the network can easily sniff and intercept traffic intended for other devices using packet analyzers. A switch directs traffic only to the specific destination port, preventing unauthorized sniffing.

(b) (i) DHCP stands for Dynamic Host Configuration Protocol. Its main function is to automatically assign IP addresses, subnet masks, default gateways, and DNS server configurations to devices dynamically when they connect to the network.
(ii) No, it cannot. An APIPA address (e.g., 169.254.x.x) is a self-assigned link-local address. It is non-routable on the Internet, meaning the device can only communicate with other local devices on the same subnet.

(c) (i) Packet filtering firewalls inspect packets at the network and transport layers (checking source/destination IP addresses, port numbers, and protocols) without examining the data payload. Application-level gateway firewalls act as a proxy, inspecting the actual contents/payload at the application layer to verify protocol-specific commands.
(ii) A rule like: "Allow incoming TCP packets from Any IP address, with source port Any, to Destination IP [Web Server IP Address] on Destination Port 80 (HTTP) or 443 (HTTPS), and block all other incoming traffic."

Marking scheme

(a)(i) 1 mark for mentioning hub broadcasts vs switch unicasts, 1 mark for relating this to reduced collisions/increased performance.
(a)(ii) 2 marks for explaining how switch isolates traffic compared to hub broadcasting, preventing packet sniffing.
(b)(i) 1 mark for the correct full name, 1 mark for describing auto-allocation of IP configurations.
(b)(ii) 1 mark for 'No', 1 mark for explaining that APIPA addresses are link-local / non-routable.
(c)(i) 1 mark for defining packet filtering (IP/port headers), 1 mark for defining application-level gateway (inspecting application payload/proxy).
(c)(ii) 2 marks for describing a complete rule indicating destination IP, protocol (TCP), and port (80 or 443).
Question 4 · Compulsory Structured Case Study
12 marks
The following algorithm is designed to find the second largest number in an array A of size N (where N >= 2). Assume all elements in array A are distinct.

```
largest = A[1]
second_largest = -999999
For i = 2 To N Do
If A[i] > largest Then
second_largest = [ (i) ]
largest = [ (ii) ]
Else If [ (iii) ] Then
second_largest = A[i]
End If
End For
```

(a) Complete the algorithm by writing down the code for blanks (i), (ii), and (iii). (4 marks)

(b) If N = 4 and A = [12, 15, 8, 14], trace the algorithm by showing the values of variables i, largest, and second_largest after each iteration. (4 marks)

(c) How many comparisons between array elements (i.e. involving A[i]) are made in the worst-case scenario for an array of size N using the above algorithm? Explain your answer. (2 marks)

(d) Briefly explain how you would modify this algorithm to find the second smallest number in array A. (2 marks)

Answer

(a)(i) largest (a)(ii) A[i] (a)(iii) A[i] > second_largest (b) Trace table values: i=2: largest=15, second_largest=12; i=3: largest=15, second_largest=12; i=4: largest=15, second_largest=14. (c) 2(N - 1) comparisons. In the worst case, both the 'If' and 'Else If' conditions are evaluated in every iteration. (d) Initialize smallest and second_smallest to a very large number, and change comparison operators from > to <.

Worked solution

(a)
(i) `largest`
(ii) `A[i]`
(iii) `A[i] > second_largest` (Accept `A[i] > second_largest And A[i] < largest`)

(b) Let's trace with N = 4, A = [12, 15, 8, 14]:
Initial: largest = 12, second_largest = -999999
- Iteration 1 (i = 2, A[2] = 15):
Since 15 > 12 is True:
second_largest = largest = 12
largest = A[2] = 15
- Iteration 2 (i = 3, A[3] = 8):
Since 8 > 15 is False,
Check Else If: 8 > 12 is False. No change. (largest = 15, second_largest = 12)
- Iteration 3 (i = 4, A[4] = 14):
Since 14 > 15 is False,
Check Else If: 14 > 12 is True:
second_largest = 14. (largest = 15, second_largest = 14)

(c) In the worst-case scenario, every element after the first (i.e. N - 1 elements) is not greater than the current `largest` but is greater than the current `second_largest` (or we simply evaluate both conditions). This forces both the `If` statement and the `Else If` statement to be evaluated. Thus, 2 comparisons are performed per iteration.
Total comparisons = \(2(N - 1)\).

(d) To find the second smallest:
1. Change initial value of `second_largest` (rename to `second_smallest`) to a very large positive number (e.g., 999999).
2. Change initial value of `largest` (rename to `smallest`) to `A[1]`.
3. Reverse all comparison operators in the conditions: change `>` to `<` in both the `If` and `Else If` statements.

Marking scheme

(a) 1 mark for blank (i), 1 mark for blank (ii), 2 marks for blank (iii).
(b) 1 mark for correct initial setup and correct values for each iteration (total 3 iterations shown clearly, 1 mark per correct iteration step).
(c) 1 mark for stating 2(N - 1) comparisons, 1 for explaining that both If and Else If checks must run.
(d) 1 mark for changing initial values to a large infinity-like number, 1 mark for reversing the comparisons from > to <.
Question 5 · Compulsory Structured Case Study
12 marks
A city is deploying IoT-enabled smart streetlights equipped with traffic cameras, environmental sensors, and wireless communication links.

(a) Describe two advantages of using IoT-enabled smart streetlights over traditional streetlights. (2 marks)

(b) The traffic cameras capture continuous real-time video to analyze traffic flow.
(i) State two potential privacy concerns raised by citizens regarding this system. (2 marks)
(ii) Suggest two technical or administrative measures that the government can adopt to address these privacy concerns. (2 marks)

(c) The streetlights upload historical environmental data to a central cloud server.
(i) State one advantage of using cloud storage instead of local storage within each streetlight. (2 marks)
(ii) State two risks of completely relying on a centralized cloud service for managing this critical city infrastructure. (2 marks)

(d) Explain how "Edge Computing" can be applied in this system to reduce network bandwidth usage. (2 marks)

Answer

(a) Smart dimming for energy efficiency, and automatic fault reporting. (b)(i) Tracking of citizens' locations, and unauthorized facial recognition. (b)(ii) Anonymize video data on-site, and establish strict data deletion policies. (c)(i) Centralized data analysis, and scalable storage without hardware limits on poles. (c)(ii) Single point of failure if the network goes down, and risk of cyberattacks on the central cloud. (d) Process video locally on the streetlight to count cars and only send numerical data instead of raw video streams.

Worked solution

(a) Advantages of IoT streetlights:
1. Dynamic/Smart dimming: Sensors can detect pedestrians/vehicles and dim lights when empty, saving energy.
2. Remote monitoring/Predictive maintenance: Broken bulbs are automatically reported to the maintenance department, eliminating the need for manual physical inspection.

(b) (i) Privacy concerns:
1. Location tracking: Citizens' daily movements and travel paths can be monitored.
2. Identification without consent: High-resolution cameras might perform facial recognition or read license plates without residents' permission.
(ii) Measures:
1. Edge-side blurring/anonymization of faces and license plates before storing or transmitting.
2. Set clear data retention policies (e.g., delete recorded video feeds after 24 hours, keeping only numerical traffic data).

(c) (i) Cloud storage enables centralized data processing and analytics across the whole city. It also reduces hardware costs on individual streetlights and ensures data is not lost if a streetlight physical unit is damaged.
(ii) Risks:
1. Network dependency: If Internet connectivity is lost, real-time control and monitoring of the streetlights will fail.
2. Security vulnerability: A centralized cloud database is a high-value target for hackers; if breached, control of all city streetlights could be compromised.

(d) Edge computing means processing data locally on the streetlight's processor (at the edge of the network). Instead of streaming heavy, high-definition raw video to the cloud, the streetlight processes the video locally to count cars/pedestrians, and only sends the light-weight numerical results (e.g., "traffic count = 15") to the cloud, dramatically reducing bandwidth consumption.

Marking scheme

(a) 1 mark for each valid advantage (e.g., energy efficiency, automatic maintenance alerts), max 2 marks.
(b)(i) 1 mark for each valid privacy concern (location tracking, facial recognition), max 2 marks.
(b)(ii) 1 mark for each valid technical/administrative measure (data masking, strict retention rules), max 2 marks.
(c)(i) 2 marks for explaining centralized management or scalability of storage.
(c)(ii) 1 mark for network connection dependency, 1 mark for cyberattack security risks.
(d) 2 marks for explaining that processing raw video locally on the device and only sending analyzed numerical metadata reduces network transmission.

Paper 2 (Elective Structured Questions)

Answer any three out of four questions in the chosen elective module paper.
3 Question · 45 marks
Question 1 · Elective Structured Case Study
15 marks
A boutique pet hotel uses a relational database to manage room reservations. The database includes the following tables:\n\nPET (PetID, PetName, Species, OwnerName, ContactNo)\nROOM (RoomNo, Category, DailyRate)\nBOOKING (BookingID, PetID, RoomNo, StartDate, EndDate, ActualCost)\n\n(a) Database Concepts:\n(i) Explain why the combination of PetID and RoomNo cannot be used as the primary key of the BOOKING table. (2 marks)\n(ii) State the referential integrity constraint that must hold between the BOOKING table and the PET table. (2 marks)\n\n(b) Normalisation:\nThe hotel manager initially designed a flat file to record invoice details:\nINVOICE (InvoiceNo, PetID, OwnerName, OwnerAddress, CheckInDate, CheckOutDate, RoomNo, RoomType, Rate)\nNote: An invoice can contain multiple rooms if the owner books several rooms for different pets under the same invoice.\n(i) Explain why this relation is not in the First Normal Form (1NF). (1 mark)\n(ii) Normalise the relation step-by-step into the Third Normal Form (3NF). State the primary keys and foreign keys clearly. (4 marks)\n\n(c) SQL Queries:\n(i) Write an SQL statement to find the total revenue (ActualCost) generated by each RoomNo in the year 2023. (3 marks)\n(ii) Write an SQL statement to list the PetID and PetName of pets who have never booked a room with the Category 'Deluxe'. (3 marks)

Answer

Detailed solution provided in the solution field.

Worked solution

(a)(i) A pet can book the same room multiple times on different dates. Therefore, the combination of PetID and RoomNo is not unique and cannot uniquely identify a booking record.\n(a)(ii) The PetID in the BOOKING table is a foreign key referencing the PetID primary key in the PET table. Every PetID in BOOKING must exist in the PET table to ensure that booking records are associated with valid registered pets.\n\n(b)(i) There is a repeating group of room details (RoomNo, RoomType, Rate) for a single invoice when multiple rooms are booked, violating the atomicity requirement of 1NF.\n(b)(ii) \n1NF:\nINVOICE (InvoiceNo, PetID, OwnerName, OwnerAddress, CheckInDate, CheckOutDate)\nINVOICE_ROOM (InvoiceNo, RoomNo, RoomType, Rate)\n\n2NF (Eliminate partial dependencies):\nINVOICE (InvoiceNo, PetID, OwnerName, OwnerAddress, CheckInDate, CheckOutDate)\nINVOICE_ROOM (InvoiceNo, RoomNo)\nROOM_DETAILS (RoomNo, RoomType, Rate)\n\n3NF (Eliminate transitive dependencies: OwnerName and OwnerAddress depend on PetID, which depends on InvoiceNo):\nINVOICE (InvoiceNo, PetID, CheckInDate, CheckOutDate) [PK: InvoiceNo, FK: PetID]\nPET_OWNER (PetID, OwnerName, OwnerAddress) [PK: PetID]\nROOM_DETAILS (RoomNo, RoomType, Rate) [PK: RoomNo]\nINVOICE_ROOM (InvoiceNo, RoomNo) [PK: (InvoiceNo, RoomNo), FK: InvoiceNo, RoomNo]\n\n(c)(i)\nSELECT RoomNo, SUM(ActualCost) AS TotalRevenue\nFROM BOOKING\nWHERE StartDate >= '2023-01-01' AND StartDate <= '2023-12-31'\nGROUP BY RoomNo;\n\n(c)(ii)\nSELECT PetID, PetName\nFROM PET\nWHERE PetID NOT IN (\n SELECT PetID\n FROM BOOKING B JOIN ROOM R ON B.RoomNo = R.RoomNo\n WHERE R.Category = 'Deluxe'\n);

Marking scheme

(a)(i) 1 mark for pointing out that a pet can make multiple bookings for the same room over time, 1 mark for explaining that it fails the uniqueness constraint of a primary key.\n(a)(ii) 1 mark for identifying the foreign key PetID in BOOKING, 1 mark for stating it must map to a valid PetID in PET.\n(b)(i) 1 mark for identifying the repeating room attributes violating atomicity.\n(b)(ii) 1 mark for correct 1NF, 1 mark for correct 2NF, 2 marks for correct 3NF with primary/foreign keys properly defined.\n(c)(i) 1 mark for SELECT with SUM and GROUP BY, 1 mark for correct WHERE date filter, 1 mark for syntactical correctness.\n(c)(ii) 1 mark for correct subquery retrieving Deluxe room bookings, 1 mark for outer query with NOT IN, 1 mark for correct projection and syntax.
Question 2 · Elective Structured Case Study
15 marks
A school is designing a web-based student council voting platform.\n\n(a) Session Management & Security:\n(i) Contrast the security of storing login states using cookies versus sessions. (2 marks)\n(ii) The system developer decides to enforce HTTPS for the connection. Briefly explain how HTTPS protects the credentials of voters in transit, and state the cryptographic technique used to establish the initial secure connection. (2 marks)\n\n(b) Client-Side vs Server-Side:\nThe system needs to validate two things:\nValidation 1: Checking if the format of the student ID entered matches the regular expression ^S[0-9]{5}$.\nValidation 2: Checking if the student has already voted.\n(i) State whether Validation 1 and Validation 2 should be implemented on the client side or the server side. Explain your choices. (4 marks)\n\n(c) AJAX and Data Interchanges:\nThe platform uses AJAX to display live results without requiring a full page refresh.\n(i) Describe how AJAX works in this scenario to fetch and display the live results dynamically. (3 marks)\n(ii) Compare XML and JSON formats for transmitting these live results in terms of data transmission size and the ease of processing within client-side JavaScript. (4 marks)

Answer

Detailed solution provided in the solution field.

Worked solution

(a)(i) Cookies are stored on the client side (browser) and can be easily tampered with or stolen via Cross-Site Scripting (XSS). Sessions are stored securely on the server side, with only a session ID stored in the client cookie, preventing users from directly viewing or altering sensitive session variables.\n(a)(ii) HTTPS encrypts all communication between the browser and the server using SSL/TLS, preventing eavesdropping and tampering. It uses asymmetric cryptography (public key cryptography) during the initial handshake to establish secure symmetric keys.\n\n(b) Validation 1: Client-side. It provides instant feedback to users without waiting for a server round-trip, improving user experience and saving server bandwidth.\nValidation 2: Server-side. Checking if a student has already voted requires querying the central database, which resides securely on the server. Client-side code can be bypassed by malicious users, so security-critical integrity checks must be on the server.\n\n(c)(i) \n1. JavaScript creates an XMLHttpRequest object or uses the Fetch API in the background.\n2. An asynchronous HTTP request is sent to the web server for the voting data.\n3. The server queries the database and sends back the data (e.g., in JSON format).\n4. JavaScript parses the response and dynamically updates the DOM to display the results without page reload.\n\n(c)(ii)\nData Transmission Size: JSON is more compact because it uses simple key-value syntax, whereas XML requires verbose opening and closing tags, leading to a larger transmission payload.\nEase of Processing in JavaScript: JSON is natively supported by JavaScript and can be directly parsed into a JS object using JSON.parse(). XML requires parsing via a DOMParser, which is much more complex and computationally heavy in JS.

Marking scheme

(a)(i) 1 mark for cookie storage location/risks, 1 mark for session storage location/security.\n(a)(ii) 1 mark for stating encryption prevents eavesdropping/tampering, 1 mark for naming asymmetric / public-key cryptography.\n(b) 1 mark for client-side (Validation 1) and server-side (Validation 2) correct allocation. 1.5 marks for explanation of Validation 1 (experience/bandwidth), 1.5 marks for explanation of Validation 2 (database security/bypassing client-side checks).\n(c)(i) 1 mark for background request initiation, 1 mark for server handling and data return, 1 mark for JS DOM update without reload.\n(c)(ii) 1 mark for JSON being smaller, 1 mark for why (no tags). 1 mark for JSON being native/easy, 1 mark for XML needing DOM parsing.
Question 3 · Elective Structured Case Study
15 marks
An algorithm needs to be developed to process and analyze data.\n\n(a) Consider the following recursive function solve(n, k):\n\n```\nfunction solve(n, k)\n if n == 0 or k == 0 then\n return 1\n else if n < k then\n return solve(n, n)\n else\n return solve(n - 1, k) + solve(n, k - 1)\n end if\nend function\n```\n\n(i) State the base cases of this recursive function. (1 mark)\n(ii) Draw a recursion tree or state the evaluation steps to find the final return value of solve(2, 2). (4 marks)\n\n(b) Algorithmic Efficiency:\nConsider an array A of size N containing distinct integers. A programmer wants to find the 2nd smallest element in the array.\nMethod 1: Sort the array in ascending order using Bubble Sort, then return the element at index 1 (the second element).\nMethod 2: Use a single pass loop to keep track of the smallest and second smallest elements.\n\n(i) State the worst-case time complexity, in Big-O notation, of Method 1 and Method 2. (2 marks)\n(ii) Write the pseudocode for Method 2. (5 marks)\n(iii) Explain why Method 2 is much more suitable than Method 1 when N is extremely large (e.g., \(N = 10^6\)). (3 marks)

Answer

Detailed solution provided in the solution field.

Worked solution

(a)(i) The base cases are when n == 0 or k == 0.\n(a)(ii) \n- solve(2, 2) = solve(1, 2) + solve(2, 1)\n- Evaluate solve(1, 2):\n Since n < k (1 < 2), solve(1, 2) = solve(1, 1)\n - solve(1, 1) = solve(0, 1) + solve(1, 0)\n - solve(0, 1) returns 1 (base case n == 0)\n - solve(1, 0) returns 1 (base case k == 0)\n - So, solve(1, 1) = 1 + 1 = 2, thus solve(1, 2) = 2\n- Evaluate solve(2, 1):\n - solve(2, 1) = solve(1, 1) + solve(2, 0)\n - We know solve(1, 1) = 2\n - solve(2, 0) returns 1 (base case k == 0)\n - So, solve(2, 1) = 2 + 1 = 3\n- Sum up: solve(2, 2) = 2 + 3 = 5.\n\n(b)(i) \nMethod 1: \(O(N^2)\)\nMethod 2: \(O(N)\)\n\n(b)(ii)\n```\nmin1 = infinity\nmin2 = infinity\nfor i from 0 to N-1 do\n if A[i] < min1 then\n min2 = min1\n min1 = A[i]\n else if A[i] < min2 then\n min2 = A[i]\n end if\nend for\nreturn min2\n```\n\n(b)(iii) \nMethod 1 with worst-case complexity \(O(N^2)\) will require around \(10^{12}\) operations when \(N = 10^6\), which will cause CPU timeout/performance bottleneck. Method 2 with \(O(N)\) complexity will execute in a fraction of a second requiring only around \(10^6\) operations, which is highly efficient and scalable.

Marking scheme

(a)(i) 1 mark for identifying both base conditions (n == 0 or k == 0).\n(a)(ii) 1 mark for correct expansion of solve(2, 2), 1 mark for correct transition of solve(1, 2) -> solve(1, 1), 1 mark for resolving base cases to obtain intermediate values, 1 mark for correct final output 5.\n(b)(i) 1 mark for each correct time complexity (Method 1: O(N^2), Method 2: O(N)).\n(b)(ii) 1 mark for initializing tracking variables to a sufficiently large value. 1 mark for correct loop structure. 1.5 marks for correct if-clause to update min1 and shift to min2. 1.5 marks for correct else-if condition to update min2.\n(b)(iii) 1 mark for mentioning the difference in efficiency class (linear vs quadratic). 1 mark for stating that as N increases, quadratic time operations grow much faster than linear. 1 mark for indicating practical performance consequences (timeout / bottleneck).