2023 JPJC P2 Question Paper
Uploaded by Kozak327 · 8 September 2026
Preview
Text from the first pages1 Name:____________________________________ Class:_____________ JURONG PIONEER JUNIOR COLLEGE JC2 Preliminary Examination 2023 COMPUTING 9569/02 Higher 2 30 August 2023 Paper 2 (Practical) 3 hours Additional materials: Cover Page Electronic version of Task1_3.txt data file Electronic version of Task2_2.txt data file Electronic version of Task4_2_1.txt data file Electronic version of Task4_2_2.txt data file Insert Quick Reference Guide READ THESE INSTRUCTIONS FIRST 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. Note that up to 6 marks out of 100 will be awarded for the use of common coding standards for programming style. The number of marks is given in brackets [ ] at the end of each task. The total number of marks for this paper is 100. This document consists of 8 printed pages. [Turn over
2 Instructions to candidates: Your program code and output for each of Task 1 to 4 should be downloaded in a single.ipynb file. For example, your program code and output for Task 1 should be downloaded as TASK1_<your class>_<your name>.ipynb. 1 Name your Jupyter Notebook as: TASK1_<your class>_<your name>.ipynb You are working as a data analyst for a research laboratory, where scientists conduct experiments and generate large datasets. To ensure accurate analysis, you need to develop a Scientific Data Analysis program that efficiently handles datasets, performs linear search to find outliers, removes them from the data, and then utilizes Quicksort to sort the remaining data for further analysis. Task 1.1 Implement a function linear_search_outliers(Data, Maximum) that takes a list of unique numerical data and a numerical maximum value as input. The function should perform a linear search to identify outliers larger than Maximum in Data and return a list containing the indices of the outliers. [5] Task 1.2 Copy and paste the code in Task1_2.txt to initialise a list of numerical data in your main program. Thereafter, use the indices from linear_search_outliers to remove the outliers larger than 90.0 from the list. You may use a not-in-place algorithm. [4] Task 1.3 Implement a recursive function quicksort(Data) that takes a list of numerical data as input, arranges the data in ascending order and return the sorted list. There are no duplicate values in the input data set. [6] Task 1.4 In the main program, use quicksort to sort the list of numerical data without outliers from Task 1.2, and display the numerical data in the sorted list. Save your Jupyter Notebook for Task 1. [2]
3 2 Name your Jupyter Notebook as: TASK2_<your class>_<your name>.ipynb You are developing a Library Management System for a college library to efficiently manage book borrowing processes. The system will use a hash table with linear probing to handle hash collisions, and the ISBN (International Standard Book Number) will be encoded to generate the hash table index using a hash function. The hash table array can store up to 53 book record objects and collisions are handled by linear probing. Task 2.1 Implement hash_function(ISBN) that takes the ISBN as a digit-string input. It calculates the integer sum of its ASCII values, perform modulo 53 to the sum and returns the remainder that will be used as the hash value. For example, hash_function(“0205080057”) returns 30. [4] Task 2.2 Implement the following Book_Record class: The to_string() method returns a string containing the values of the four attributes separated by a comma and a space. Book_Record ISBN: STRING Title: STRING Author: STRING Due_Date: STRING Constructor(ISBN, Title, Author, Due_Date) Get_ISBN(): STRING Get_Title(): STRING Get_Author(): STRING Get_Due_Date(): STRING Set_Due_Date(new_due_date) to_string(): STRING [5] Task 2.3 Write a Python program to: create a hash table array hta, reads book records from a text file Task2_3.txt, where each line in the file contains book information in the format: ISBN,Title,Author,Due_Date and create Book_Record objects, use hash_function to generate the hash value for each Book_Record object, and use the value to insert the Book_Record object into the hta, and use linear probing to handle collision. [6] [Turn over
4 Task 2.4 Implement a function search_book_record(hta) that allows the library staff to find a book's information by entering its ISBN. The function should prompt the user to input the ISBN of the book to be searched, retrieve the Book_Record object using hash table search and return its information from to_string() method, or “Book not on loan” if not found. [4] Task 2.5 Write the program to search and display the information for the following ISBNs: 0205080057 1234567890 [2] Task 2.6 Implement a procedure update_book_record(hta) that allows the library staff to update a book's due date by entering its ISBN. The procedure should prompt the user to input the ISBN of the book to be updated, retrieve the Book_Record object from the hash table and update its Due_date. You may assume the ISBN entered will exist in the hash table. Task 2.7 Write the program to: update the due date of the book with ISBN 0679760806 to 2023-09-01 display the updated hash table with index and book information in neat columns. The following is a sample partial output: Save your Jupyter Notebook for Task 2. [4] [2]
5 3 Name your Jupyter Notebook as: TASK3_<your class>_<your name>.ipynb The linked list is implemented as a collection of nodes in object-oriented programming. The Node class contains two properties: data is the data in the node next points to the next node A stack, used to store string values, is implemented using a linked list. The Stack class contains one property: top is a pointer to the node at the top of the stack. The Stack class contains the following methods: constructor to set top to None, push(word) will insert word to the top of the stack, pop() will remove and return the top element in the stack, and to_string() returns a string containing the elements starting from the top, separated by a comma and a space, e.g.: in the form: apple, orange, pear Task 3.1 Write the Node class and the Stack class. [10] Task 3.2 Write program code to: declare a new instance of Stack store each value from the following list lst as a new node in the stack, lst = ['plane','bus','car','train','yacht','ship'] print the resulting content in the stack using the to_string() method print the first three elements to be popped from the stack [3] Task 3.3 A queue, used to store string values, is also implemented using a linked list. The Queue class contains one property: head is a pointer to the node at the head of the queue. The Queue class contains the following methods: constructor to set head to None, enqueue(word) will insert word to the end of the queue, dequeue() will remove and return the first element in the queue, and to_string() returns a string containing the elements starting from the head, separated by a comma and a space. Write the Queue class. [
Content continues in the PDF. Download PDF
Related notes
- 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
- 1992 AJC Computing QPExam Papers · 1992
- 2023 YIJC P2 Question PaperExam Papers · 2023
- 2023 YIJC P1 Question PaperExam Papers · 2023
- 2023 RVHS P2 CombinedExam Papers · 2023
- 2023 RI P2 Question PaperExam Papers · 2023
- 2023 RI P1 Question PaperExam Papers · 2023
- 2023 NYJC-VJC-TJC P2 Question PaperExam Papers · 2023
- 2023 NJC P2 Question PaperExam Papers · 2023
- See all H2 Computing notes

