2024 ASR H2 Computing Prelim P1 Sol
Uploaded by Kozak327 · 25 August 2026
Preview
Text from the first pagesASRJC 2024 [Turn over COMPUTING 9569/01 Paper 1 (Written) Suggested Answers 11 September 2024 (Wednesday) 3 hours READ THESE INSTRUCTIONS FIRST An answer booklet will be provided with the question paper. You should follow the instructions on the front cover of the answer booklet. If you need additional writing paper ask the invigilator for a continuation booklet. Answer all questions. Approved calculators are allowed. 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. This document consists of 6 printed pages and 0 blank page. Anderson Serangoon Junior College ANDERSON SERANGOON JUNIOR COLLEGE JC2 Preliminary Examination 2024 Higher 2
2 ASRJC 2024 1 A gym's membership management system uses Object Oriented Programming (OOP) in its design. The gym offers three types of membership: Basic, Pro and Family. For every gym member, its member ID, name, mobile number and membership start date need to be stored. The system should also allow for the annual renewal of membership. Basic members are only allowed non-peak hours gym usage daily. There are no restricted hours for Pro and Family memberships. Pro members are entitled to 10 complimentary training sessions with a qualified personal trainer of choice. For Family members, up to three family members' names can be stored. Basic members will be charged a monthly fee, while Pro members will be charged 1.3 times this rate. Each Family member will be charged 1.5 times this rate, with each additional family member being charged 0.5 times this rate. Membership fees are charged via a calculate_fee() method at the start of each membership cycle. (a) For the Basic base class, explain how encapsulation can be achieved. [2] ● Encapsulation - grouping of data and methods within a class entity with protected access ● Define all attributes of the class as private to prevent direct access to the data from outside the class. ● Provide public methods to access and modify the private attributes to allow controlled access to the data (b) Explain the rationale of creating the Pro and Family subclasses. [2] ● Inheritance - ability of subclasses to adopt data(state) and methods(functionality) from superclass ● Leverage by reusing common data/state and methods/functionality from superclass without reinventing the wheel or unnecessary code duplication (better readability and maintainability) ● Override and/or Implement data and methods specific to the subclasses allowing them to have new/extended state and functionality (c) How does this class relationship demonstrate polymorphism? [3] ● Polymorphism - ability to invoke different methods(behaviour) using the same method name, promoting code generalisation ● By having different classes implementing their specific calculate_fee() method, different computation of membership fees can be effected using the same method call without the use of conditional checks for membership types/classes ● eg b1, p1, f1 representing objects of Basic, Pro and Family classes respectively members = [b1, p1, f1] for member in members: member.calculate_fee()
3 ASRJC 2024 [Turn over (d) Draw a class diagram for this system showing the base class and the derived classes, including relevant attributes and methods necessary for the system to function. [6] (e) The gym business owner wishes to launch a referral promotion for members to refer their friends to join the gym. Each successful referral will extend an existing member's current membership validity period by one month. Describe the necessary change(s) that can be made to the class diagram to accommodate this updated requirement. [2] ● add membership end date attribute and referral() method to superclass Basic ● upon every successful referral, invoke referral() method to extend membership end date by one month ● modify calculate_fee() method to trigger fee payable using membership end date accept other reasonable answers 2 ABC School has the following workflow for teachers to apply for vacation leave.
4 ASRJC 2024 Note: ● Each teacher has a reporting supervisor ● HRP (Human Resource Portal) is an online platform for teachers to access services such as leave application (a) Convert the workflow to a decision table, showing all possible conditions and actions. [3] Conditions Weekend and/or public holiday? Y Y N N During protected time? Y N Y N Actions Obtain supervisor approval X X X X Obtain P approval via email X Apply P approval via HRP X X (b) Simplify your decision table in (a) by removing redundancies. [2] Conditions Weekend and/or public holiday? Y N N During protected time? - Y N
5 ASRJC 2024 [Turn over Actions Obtain supervisor approval X X X Obtain P approval via email X Apply P approval via HRP X X (c) Translate the decision table to pseudocode using appropriate variables. [4] FUNCTION ApplyVacationLeave(isWeekendOrHoliday, isProtectedTime) // Initialize actions obtainSupervisorApproval = true // Always obtain supervisor approval obtainPApprovalViaEmail = false applyPApprovalViaHRP = false IF isWeekendOrHoliday obtainPApprovalViaEmail = true ELSE IF isProtectedTime applyPApprovalViaHRP = true ELSE obtainPApprovalViaEmail = true applyPApprovalViaHRP = true ENDIF // Return required actions RETURN [obtainSupervisorApproval, obtainPApprovalViaEmail, applyPApprovalViaHRP] ENDFUNCTION 3 The Fibonacci sequence is a series of numbers in which each number is the sum of the two previous numbers: 1, 1, 2, 3, 5, 8, … (a) Draw a program flowchart to iteratively compute the nth Fibonacci number, n > 0. [3]
6 ASRJC 2024 (b) The following pseudocode shows an algorithm to iteratively compute the nth Fibonacci number: 01 FUNCTION fibonacci_iterative(n) 02 IF n <= 2 03 return n 04 ENDIF 05 a = 1 06 b = 1 07 FOR i FROM 2 TO n 08 temp = a + b 09 a = b 10 b = temp 11 ENDFOR 12 RETURN b 13 ENDFUNCTION Identify (specify line numbers) and rectify two logic errors with the above algorithm. [4] ● line 03 incorrectly returning initial values ● correction: return 1 ● line 07 incorrect starting value in for loop ● correction: FOR i FROM 3 to n (c) Produce the pseudocode for a fibonacci_recursive(n) algorithm to determine the nth Fibonacci number recursively. [3] FUNCTION fibonacci_recursive(n): IF n <= 2 RETURN 1 ELSE RETURN fibonacci_recursive(n - 1) + fibonacci_recursive(n - 2) ENDIF
7 ASRJC 2024 [Turn over ENDFUNCTION (d) Why is recursive Fibonacci less efficient than iterative Fibonacci for large n? [2] ● Redundant calculations: recursive approach recalculates the same Fibonacci numbers multiple times. For example, to calculate F(5), it calculates F(4) and F(3). But to calculate F(4), it again calculates F(3). This redundancy grows exponentially as n increases. ● Call stack overhead: each recursive call adds a new frame to the call stack. For large n, this can lead to stack overflow errors if the recursion depth exceeds the available stack space. (e) Suggest a way to overcome the issue identified in (d). [3] ● memoisation to store c
Content continues in the PDF. Download PDF
Related notes
- JPJC 2024 JC2 Prelim Paper 2 QPExam Papers · 2024
- JPJC 2024 JC2 Prelim Paper 2 MS v2Exam Papers · 2024
- JPJC 2024 JC2 Year-End Exam H2 Computing Paper 1Exam Papers · 2024
- JPJC 2024 JC2 Year-End Exam H2 Computing Paper 1 Marking SchemeExam Papers · 2024
- 2024 ASR H2 Computing Prelim P1 QnsExam Papers · 2024
- 2025 VJC H2 Computing Prelim Paper 1Exam Papers · 2025
- 2025 VJC H2 Computing Prelim Paper 1 SolutionsExam Papers · 2025
- 2025 TJC H2 Computing Prelim Paper 1 SolutionsExam Papers · 2025
- RVHS 2025 H2 Computing Prelim Paper 1Exam Papers · 2025
- RVHS 2025 H2 Computing Prelim Paper 1 SolutionsExam Papers · 2025
- RI 2025 H2 Computing Prelim Paper 1Exam Papers · 2025
- RI 2025 H2 Computing Prelim Paper 1 SolutionsExam Papers · 2025
- See all H2 Computing notes

