DHS 2026 Y6 H2 Computing Prelim Paper 2 final
Uploaded by Kozak327 · 4 October 2026
Preview
Text from the first pagesThis document consists of 14 printed pages. Name: Index Number: Class: DUNMAN HIGH SCHOOL Preliminary Examination Year 6 COMPUTING (Higher 2) 9569/02 Paper 2 (Lab-based) 24 August 2026 3 hours Additional Materials: Insert Electronic version of plaintext.txt file Electronic version of publickey.txt file Electronic version of privatekey.txt file Electronic version of CLIENT.py file Electronic version of prelim_results.json file READ THESE INSTRUCTIONS FIRST Write your name, index number and class on the work you hand in. Write in dark blue or black pen on both sides of the paper. You may use an HB pencil for any diagrams or graphs. Do not use staples, paper clips, glue or correction fluid. Answer all the questions. All tasks must be done in the computer laboratory. You are not allowed to bring in or take out any pieces of work or materials on paper or electronic media or in any other form. Approved calculators are allowed. Save each task as it is completed. The use of built-in functions, where appropriate, is allowed for this paper unless stated otherwise. The number of marks is given in brackets [ ] at the end of each question or part question. The total number of marks for this paper is 100. [Turn over
2 DHS 2026 Year 6 H2 Computing Preliminary Examination Paper 2 Instructions to candidates: Your program code and output for Task s 1 to 3 should be saved in a single .ipynb file each using Jupyter Notebook. For example, your program code and output for Task 1 should be saved as: TASK1_<your name>_<centre number>_<index number>.ipynb Make sure that each of your .ipynb files shows the required output in Jupyter Notebook. 1 The Rivest -Shamir-Adleman (RSA) algorithm is the industrial standard for asymmetric encryption. Its benefit is it removes the need for the sender and receiver to exchange encryption keys. The sender encrypts the message with the receiver's public key, made readily available over the internet. After the message is transmitted, all the receiver needs to do is to decrypt using the receiver's private key. Using a simplified RSA algorithm, plaintext data in source file plaintext.txt will be encrypted using the public key, then decrypted using a separate private key. Both keys are stored in source files publickey.txt and privatekey.txt, and the math linking them has been abstracted to keep things simple. The public and private keys are defined as tuples (e, n) and (d, n) respectively, where e is the public exponent, d the private exponent and n is the modulus. Note that all calculations are on ASCII values. The encryption formula is: encrypted_char = char e mod n To decrypt: decrypted_char = encrypted_char d mod n For each of the sub-tasks, add a comment statement at the beginning of the code, using the hash symbol ‘#’ to indicate the sub -task the program code belongs to, for example: Task 1.1 The text files publickey.txt and privatekey.txt each contain a key made up of 2 numbers separated by a comma. Write program code for the function load_key() that takes a filename as a parameter, reads the file and returns the key as a tuple of integers. [3] Program code Output: #Task 1.1
3 DHS 2026 Year 6 H2 Computing Preliminary Examination Paper 2 Task 1.2 The text file plaintext.txt contains unencrypted string data. Write program code for the function load_message() that takes a filename as a parameter and returns the string contents of the file. [2] Task 1.3 Write program code for the function encrypt_message() that takes message string, public exponent integer e and modulus integer n as three parameters. It performs RSA encryption on each character in message and returns a list of integer values. [5] Task 1.4 Write program code for the function decrypt_message() that takes a list of encrypted integer values, private exponent integer d and modulus integer n as three parameters. It performs RSA decryption on each value in the list and returns a string of decrypted characters. [5] Task 1.5 Write program code to: 1. call the function load_key() on publickey.txt and privatekey.txt to load the public and private keys 2. call the function load_message() on plaintext.txt to load the plaintext message to be encrypted 3. call the function encrypt_message() to encrypt the message 4. call the function decrypt_message() to encrypt the message Output the results in every step. [4] Save your Jupyter Notebook for Task 1. [Turn over
4 DHS 2026 Year 6 H2 Computing Preliminary Examination Paper 2 2 A Simple File Storage Scheme called SFSS manages the allocation of computer storage nodes when creating and deleting files in a computer system. It uses a free space pointer to keep track of the free space list, a dictionary as a file directory and a fixed size array to store the nodes. It can allocate free nodes to create new files and return unused nodes back to the free space list when files are deleted. Each file is thus a linked list populated by nodes kept inside an array, with the filename and starting node stored in the dictionary. The free space list is also a linked list maintained by a free space pointer, which is set to -1 if it is empty. A node is initialised with empty string as data and pointer as -1 . The array is initialised to contain a fixed number of unused nodes, with the pointer of each node initialised to point to the next node, except the last node which terminates the free space list with pointer kept as -1. The free space pointer is initialised to point to the first node of the array. When a new file needs to be created, SFSS will assign and link a suitable number of nodes to store data. Each node can only store one character of data. Subsequently, it will create a key-value pair in the dictionary with filename as key and the starting node of the file data as value. For exampl e, when 'file1' containing data 'ace' and 'file2' containing 'man' are added, in that order, into a 10 node SFSS instance, the directory, free space pointer and array look like this: File Directory: {'file1': 0, 'file2': 3} Free space pointer: 6 Array State: Index | Data | Next 0 | a | 1 1 | c | 2 2 | e | -1 3 | m | 4 4 | a | 5 5 | n | -1 6 | | 7 7 | | 8 8 | | 9 9 | | -1 When a file is deleted, SFSS will return the nodes freed up by the file deletion by traversing the file's linked list from the front, linking each node to the front of the free space list, until the end of file is reached. For better visualisation, the data in the unused node is then overwritten with an empty string. For example, when 'file1' is deleted, the directory, free space pointer and array look like this: File Directory: {'file2': 3} Free space pointer: 2 Array State: Index | Data | Next 0 | | 6 1 | | 0 2 | | 1 3 | m | 4 4 | a | 5 5 | n | -1 6 | | 7 7 | | 8 8 | | 9 9 | | -1
5 DHS 2026 Year 6 H2 Computing Preliminary Examination Paper 2 Name your Jupyter Notebook as: TASK2_<your name>_<centre number>_<index number>.ipynb For each of the sub-tasks, add a comment statement at the beginning of the code, using the hash symbol ‘#’ to indicate the sub -task the program code belongs to, for example: Task 2.1 The class Node contains two attributes: • data: the node's single character data, initialised as an empty string • pointer: the node's next pointer, initialized to -1 The class Node has the following methods: • a constructor to initialise the two attributes • set_data() that assigns a value to data • set_pointer() that assigns a value to point
Content continues in the PDF. Download PDF
Related notes
- NYJC 2026 Prelim P2Exam Papers · 2026
- NYJC 2026 Prelim P1Exam Papers · 2026
- ACJC 2026 JC2 Computing Prelim Paper 2 (Practical)Exam Papers · 2026
- 2026_NJC Prelim_Computing_P2.pdfExam Papers · 2026
- 2026_JPJC_Computing_Prelim_P2_finalExam Papers · 2026
- 2026_JPJC_Computing_Prelim_P1_markschemeExam Papers · 2026
- 2026_JPJC_Computing_Prelim_P1_finalExam Papers · 2026
- 2026 ACJC Prelim Computing Paper 2Exam Papers · 2026
- 2024 ACJC Computing PromoExam Papers · 2024
- 2023 ACJC Promo QPExam Papers · 2023
- 2022 ACJC Computing Promo Paper 2Exam Papers · 2022
- 2021 ACJC Computing Promo Paper 2Exam Papers · 2021
- See all H2 Computing notes

