The following is a procedure design in pseudocode. Line numbers are given for reference only. 10 PROCEDURE Check(InString : STRING) 11 DECLARE Odds, Evens, Index : INTEGER 12 13 Odds ← 0 14 Evens ← 0 15 Index ← 1 16 17 WHILE Index <= LENGTH(InString) 18 IF STR_TO_NUM(MID(InString, Index, 1)) MOD 2 <> 0 THEN 19 Odds ← Odds + 1 20 ELSE 21 Evens ← Evens + 1 22 ENDIF 23 Index ← Index + 1 24 ENDWHILE 25 26 CALL Result(Odds, Evens) 27 ENDPROCEDURE
- (a)Complete the following table by giving the answers, using the given pseudocode. A line number containing a variable being incremented The type of loop structure The number of functions used The number of parameters passed to STR_TO_NUM() The name of a procedure other than Check() Answer[5]
- (b)The pseudocode includes several features that make it easier to read and understand. Identify three of these features. 1 2 3[3]
- (c)(i)The loop structure used in the pseudocode is not the most appropriate. State a more appropriate loop structure and justify your choice. Loop structure Justification[2]
- (c)(ii)The appropriate loop structure is now used. Two lines of pseudocode are changed and two lines are removed. Write the line numbers of the two lines that are removed.[1]
Mark scheme
Marking points from the official mark scheme (Oct/Nov 2021). The mark or mark type is shown in brackets.
- [1] A line number containing a variable being incremented: 19 / 21 / 23
- [1] The type of loop structure: pre-condition
- [1] The number of functions used: 3
- [1] The number of parameters passed to STR_TO_NUM(): 1
- [1] The name of a procedure other than Check(): Result
- [1] Meaningful variable names
- [1] Indentation / white space / blank lines
- [1] Capitalisation of keywords
- [1] Loop structure: A count-controlled loop
- [1] Justification: The number of iterations is known // repeats for the length of InString
- [1] 15, 23
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 →