Note AcademyNote Academy

Computer Science · Oct / Nov 2024 · Paper 21 · Question 6

0478

As printed in the paper

The question as text

An incomplete algorithm has been written in pseudocode to count the number of zeros stored in an array and total the non-zero values. € ƒ„ †‡ˆ„ ‡‰Š‹€Œ Š Ž„„ˆ €‘ ƒ„ †‡ˆ„ Š Ž„„ˆ €’ ƒ„ †‡ˆ„  Š Ž„„ˆ €“ ƒ„ †‡ˆ„  Š Ž„„ˆ €‹  ” € €• €– —˜ˆ ”  ˜ ‹€ €™ — ‡‰ Œ €š ›„Ž €  ”  œ   „†„ ‘  ”  œ ‡‰ Œ ’ „Žƒ— “

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

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

    One mark for each point (max three)

    06 T ← 0
    08 IF A[C] = 0
    14 NEXT C // NEXT
  • 6(b)[3]

    One mark for outputting T

    One mark for outputting I

    One mark for suitable messages

    Example:

    15 OUTPUT "Number of zeros in the array is ", T

    16 OUTPUT "Total of non-zero elements in the array is ", I

  • 6(c)[3]

    One mark for a meaningful identifier for the array

    A MyArray

    One mark for 2 meaningful identifiers, Two marks for 3 meaningful identifiers:

    T Counter

    C Index

    I Total

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