Question 2
AQA Computer Science November 2021 Paper 1 (8520/1)GCSE7 marks
On the specification
- 2.1
- 3.2 Programming
- 2.2
- 3.2 Programming
- 2.3
- 3.2 Programming
- 2.4
- 3.1 Fundamentals of algorithms3.2 Programming
Question text
2 box The algorithm shown in Figure 1 is designed to help an athlete with their training. It uses two subroutines getBPM and wait: • getBPM() returns the athlete’s heart rate in beats per minute from an external input device • wait(n) pauses the execution of the algorithm for n seconds, so wait(60) would pause the algorithm for 60 seconds. Line numbers have been included but are not part of the algorithm. Figure 1 1 seconds ← 0 2 rest ← 50 3 REPEAT 4 bpm ← getBPM() 5 effort ← bpm – rest 6 IF effort ≤ 30 THEN 7 OUTPUT 'faster' 8 ELSE 9 IF effort ≤ 50 THEN 10 OUTPUT 'steady' 11 ELSE 12 OUTPUT 'slower' 13 ENDIF 14 ENDIF 15 wait(60) 16 seconds ← seconds + 60 17 UNTIL seconds > 200 2.1 State the most appropriate data type of the variable seconds in the algorithm shown in Figure 1. [1 mark] 2.2 Explain why rest could have been defined as a constant in the algorithm shown in Figure 1. [1 mark] 2.3 State the line number where iteration is first used in the algorithm shown in box Figure 1. [1 mark] 2.4 Complete the trace table for the algorithm shown in Figure 1. Some values have already been entered in the trace table: • the first value of seconds • the values returned by the subroutine getBPM that are assigned to the variable bpm. You may not need to use all rows of the trace table. [4 marks] seconds bpm effort OUTPUT 0 70 80 100 120