HKDSE · Thinka-original Practice Paper

2022 HKDSE Information and Communication Technology Practice Paper | DSE Mock

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
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.
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)
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.
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
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
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.
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
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.
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`
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.
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
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.
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)
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
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.
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.
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)
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
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
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
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
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)
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
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.
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]
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;
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
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)
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
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
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)
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)
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)
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
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`
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)
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
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
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

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

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