Note AcademyNote Academy

Computer Science · May / June 2025 · Paper 22 · Question 5

0478

As printed in the paper

The question as text

This pseudocode algorithm should allow 500 names of people and their heights to be entered and stored in two one-dimensional (1D) arrays. The name of a person and the height of that person are in the same index in both the ƒ ‡‰Š‹ and the ‡‘’“”‰Š‹ arrays. The algorithm performs as follows: • at the start, the following data is entered:  name of person  height of person in cm • the data is stored in the relevant arrays • the heights of the people are totalled • the shortest person is found • at the end, the following is output:  name of shortest person  height of shortest person  average height of all 500 people. –— ˜™š›œ™ ƒ ‡‰ ž œœŸŠ—ž ––‹ ¡¢ ™œ› –£ ˜™š›œ™ ‡‘’“”‰ ž œœŸŠ—ž ––‹ ¡¢ ™œ› –¤ ˜™š›œ™ ¥“¦ˆ”‡‰” ž ™œ› –§ ˜™š›œ™ ¨¦”© ž ™œ› – ˜™š›œ™ š¦„ª”‡ˆ ž «ƒ¨™¬™ –­ ˜™š›œ™ «ª®‡¯ ž «ƒ¨™¬™ –° ¥“¦ˆ”‡‰” –– –± «ª®‡¯ – –² ¨¦”© —–– —– ¢¡ š¦„ª”‡ˆ — ¨¡ –– —— «ƒ³´¨ ƒ ‡‰Š«ª®‡¯‹ —£ «ƒ³´¨ ‡‘’“”‰Šš¦„ª”‡ˆ‹ —¤ ¨¦”© š¦„ª”‡ˆ µ ‡‘’“”‰Šš¦„ª”‡ˆ‹ —§ «¢ ‡‘’“”‰Šš¦„ª”‡ˆ‹ ¶ ¥“¦ˆ”‡‰” — ¨™ƒ —­ ¥“¦ˆ”‡‰” ‡‘’“”‰Šš¦„ª”‡ˆ‹ —° «ª®‡¯ š¦„ª”‡ˆ —± ™ƒ˜«¢ —² ƒ™·¨ š¦„ª”‡ˆ £– ¡´¨³´¨ ¸¨“‡ ‰“¦ˆ”‡‰” “‡‘’“” ‘‰ ¸¹ ‡‘’“”‰ £— ¡´¨³´¨ ¸¨“‡ ‰“¦ˆ”‡‰” º‡ˆ‰¦ª ‘‰ ¸¹ ƒ ‡‰Š«ª®‡¯‹ ££ ¡´¨³´¨ ¸¨“‡ »‡ˆ’‡ “‡‘’“” ‘‰ ¸¹ ¨¦”© ¼ ––

Read automatically from the paper; the printed page above is exact.

Show the answer and mark scheme
  • 5(a)[5]

    One mark per mark point

    Line 01 / DECLARE Names : ARRAY[1:500] OF REAL

    should be DECLARE Names : ARRAY[1:500] OF STRING

    Line 09 / Total ← 100

    should be Total ← 0

    Line 11 / INPUT Names[Index]

    should be INPUT Names[Counter]

    Line 13 / Total ← Counter + Heights[Counter]

    should be Total ← Total + Heights[Counter]

    Line 20 / OUTPUT "The shortest height is ", Heights should be OUTPUT "The shortest height is ", Shortest or OUTPUT "The shortest height is ", Heights[Index] 01 DECLARE Names : ARRAY[1:500] OF STRING

    02 DECLARE Heights : ARRAY[1:500] OF REAL

    03 DECLARE Shortest : REAL

    04 DECLARE Total : REAL

    05 DECLARE Counter : INTEGER

    06 DECLARE Index : INTEGER

    07 Shortest ← 500

    08 Index ← 0

    09 Total ← 0

    10 FOR Counter ← 1 TO 500

    11 INPUT Names[Counter]

    12 INPUT Heights[Counter]

    13 Total ← Total + Heights[Counter]

    14 IF Heights[Counter] < Shortest

    15 THEN

    16 Shortest ← Heights[Counter]

    17 Index ← Counter

    18 ENDIF

    19 NEXT Counter

    20 OUTPUT "The shortest height is ", Shortest

    21 OUTPUT "The shortest person is ", Names[Index] 22 OUTPUT "The average height is ", Total / 500

  • 5(b)[2]

    One mark per mark point

    MP1 Output statement with correct calculation of average, or use of a variable average.

    MP2 Correct use of ROUND function set to 1 decimal place.

    For example,

    OUTPUT ROUND(Total / 500, 1)

  • 5(c)[4]

    One mark per statement, max four

    MP1 Declaration of new variable for tallest person / largest value at start of algorithm

    MP2 Initialisation of largest variable to a low number e.g. 0

    MP3 New selection statement after input of height to compare it with current largest value

    MP4 If input of height is larger than current largest variable, it should become the new largest value

    MP5 Outside the loop, output the current value of the largest variable.

Make a free account to save your answers and see your weak topics and ask the AI why a wrong answer is wrong.