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 rea...

Assessment: Computer Science 4CP0 | Paper 2 Mock 01 | Written Paper 2 Subject: Computer Science - 4CP0

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.

Fig. 1: sentinel-controlled looptotal ← 0INPUT durationduration = -1?yes: DISPLAY totalno: total ← total + duration, repeat

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]

Answer Details

(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]

Download The App On Google Playstore

Everything you need to excel in your exams

Green Bridge CBT Mobile App
Personalized AI Learning Chat Assistant
200,000+ Exam Questions Across IGCSE, JAMB, WAEC & NECO
Over 3,900 Lesson Notes
Offline Support - Learn Anytime, Anywhere
Green Bridge Timetable
Literature Summaries & Potential Questions
Track Your Performance & Progress
In-depth Explanations for Comprehensive Learning