Question 1 Report
Fig. 1 shows an algorithm used by a community radio station to calculate the total length of a playlist. Each item is a duration in seconds. The program reads a list until it reaches the end marker -1, which is not included in the total. It then displays the result in seconds. The station manager uses the output to check that a programme fits within its scheduled slot.
The input sequence is 185, 212, 96, -1.
(a) Identify the sentinel value. [1]
(b) Write the value of total after the second item. [1]
(c) State the final displayed number. [1]
(d) Give one reason why -1 is suitable as an end marker for a duration. [1]
(e) Use the algorithm to state whether 500 s is exceeded. [1]
(a) The sentinel value is -1. [1] A sentinel is a special value used to signal that input has ended.
(b) After the first two durations:
\[185+212=397\]
So total is 397. [1]
(c) The sentinel is not added:
\[185+212+96=493\]
The final displayed number is 493. [1]
(d) -1 is suitable because a duration cannot be negative. [1] It cannot be confused with a genuine track duration.
(e) No, 500 s is not exceeded because the total is 493 s. [1]
Everything you need to excel in your exams