Refer to the insert for the list of pseudocode functions and operators. 1 The following pseudocode represents part of the algorithm for a program: CASE OF ThisValue < 30 : Level ← "Low" // less than 30 Check ← 1 < 20 : Level ← "Very Low" // less than 20 Check ← ThisValue / 2 30 TO 40 : Level ← "Medium" // between 30 and 40 Check ← ThisValue / 3 Data[ThisValue] ← Data[ThisValue] + 1 > 40 : Level ← "High" ENDCASE
- (a)Complete the table by writing the answer for each row: The value assigned to Level when ThisValue is 40 The value assigned to Check when ThisValue is 36 The value assigned to Level when ThisValue is 18 The number of elements in array Data that may be incremented Answer[4]
- (b)The pseudocode contains four assignments to variable Level. One of these assignments will never be performed. Identify this assignment and explain why this is the case.[3]
- (c)The following line is added immediately before the ENDCASE statement: OTHERWISE : Level ← "Undefined" State why this assignment is never performed.[1]
- (d)Give the appropriate data types for the variables ThisValue, Check and Level. ThisValue Check Level[3]
Mark scheme
Marking points from the official mark scheme (Oct/Nov 2023). The mark or mark type is shown in brackets.
- [1] The value assigned to Level when ThisValue is 40: "Medium"
- [1] The value assigned to Check when ThisValue is 36: 12
- [1] The value assigned to Level when ThisValue is 18: "Low"
- [1] The number of elements in array Data that may be incremented: 11
- [1] Level ← "Very Low"
- [1] because CASE clauses are checked in sequence / because of the order of the clauses
- [1] a value < 30 satisfies the first clause / Clause '< 20' will never be tested
- [1] all of the possible values are addressed via all / four / three / the other clauses / there are no other possible values to map to OTHERWISE
- [1] ThisValue: INTEGER
- [1] Check: REAL
- [1] Level: STRING
Write your answer and get it marked
On Oracle Prep you can write or photograph your own answer and have it marked by AI against this mark scheme, with feedback on what you missed.
Sign up free →