2024_H2_CP_Paper 1 suggested solution
Uploaded by ajjj · 27 April 2025
Preview
2024 A Level H2 Computing Paper 1 Suggested solution 1 (a)
1 (b) c i n OUTPUT 0 72 0 72 69 0 69 72 1 69 76 1 76 69 1 76 76 1 76 76 2 76 79 2 79 76 2 79 -1 2 -1 79 2 (c) It counts the number of times the next letter’s ASCII code is greater than the current one. (d) (i) 79 = 16 * 4 + 15. Therefore, 79 in hexadecimal is 4F Denary Quotient Remainder Hexadecimal 79 / 16 4 15 4 15 /16 0 15 F (ii) 79 = 2^(6) + 2^(3) + 2^(2) + 2^(1) + 2^(0). Therefore, 79 in binary is 1001111 Denary Quotient Remainder 79 / 2 39 1 39 / 2 19 1 19 / 2 9 1 9 / 2 4 1 4 / 2 2 0 2 / 2 1 0 1 / 2 0 1 (iii) ASCII is restricted to 128 or 256 characters, depending on whether it's 7-bit or 8-bit. ASCII can only represent characters from English languages. It is unable to support
other non-English languages when encoding characters such as accented letters and non-Latin scripts (Chinese, Arabic etc) 2 (a) (b) It is defined in terms of itself since S(n-1) is in the function. It calls itself with a smaller problem as seen in Line 05: RETURN S(n-1) - 3. It has a terminating condition when n = 1 as shown in Line 02. (c) When S(2) is called by the main program, the return address to main is pushed onto the stack. S(2) calls S(1) and the return address to S(2) and the content of n = 2 is pushed onto the stack. Since the base case is reached, 12 is pushed onto the stack. 12 is popped together with the stack frame and is return to S(2). Push new value of 12 – 3 = 9 onto the stack. Pop 9 and return to main. (d) If S(0) is called, it will continuously call itself and ends up in an infinite loop as it will not reach its base case of n = 1. Eventually, it will result in a runtime error caused by stack overflow. (e) FUNCTION S(n : INTEGER) RETURNS INTEGER RESULT 12 WHILE n <> 1 RESULT RESULT – 3 n n − 1 ENDWHILE RETURN RESULT ENDFUNCTION S(5) S(4) S(3) S(2) S(1) Returns 12 Returns 12 – 3 = 9 Returns 9 – 3 = 6 Returns 6 – 3 = 3 Returns 3 – 3 = 0
3 (a) (b) Instantiation is the process when an object of a class is created. (c) (i) Encapsulation is when the private attributes of a class can only be accessed by calling the public method. An example would be to access the private attribute status for Bee, it can only be done by calling the public method get_status(). (ii) Inheritance is when the subclass is derived from the superclass and has its attributes and methods. An example would be Drone, which is a subclass that is derived from its superclass Bee, acquires all the attributes and methods from its superclass. (iii) Polymorphism is when the subclass defines a method with the same name as the method in the superclass but is modified for different behaviour. An example would be the set_energy() method in Queen, which decreases energy by 2, behaves differently from the set_energy() method in Drone, which decreases energy by 1.
(d) Ty
Content continues in the PDF.
Related notes
- VJC Chapter 21 SQLite with PythonNotes/Practices · 2025
- VJC Chapter 23 Web Applications PrinciplesNotes/Practices · 2025
- VJC Chapter 10 RecursionNotes/Practices · 2025
- VJC Chapter 20 SQLNotes/Practices · 2025
- VJC Chapter 16 Hash TableNotes/Practices · 2025
- VJC Chapter 22 NoSQLNotes/Practices · 2025

