The algorithm shown in Figure 1 is designed to help an athlete with their training - AQA - GCSE Computer Science - Question 2 - 2021 - Paper 1
Question 2
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 ... show full transcript
Worked Solution & Example Answer:The algorithm shown in Figure 1 is designed to help an athlete with their training - AQA - GCSE Computer Science - Question 2 - 2021 - Paper 1
Step 1
State the most appropriate data type of the variable seconds in the algorithm shown in Figure 1.
96%
114 rated
Only available for registered users.
Sign up now to view full answer, or log in if you already have an account!
Answer
The most appropriate data type of the variable seconds is an Integer or Int. This is because seconds represents a count of time, which is inherently a whole number.
Step 2
Explain why rest could have been defined as a constant in the algorithm shown in Figure 1.
99%
104 rated
Only available for registered users.
Sign up now to view full answer, or log in if you already have an account!
Answer
rest could have been defined as a constant because its value (50) does not change throughout the execution of the algorithm. Since it is initialized and not modified during the algorithm's operation, defining it as a constant would enhance clarity and mean it can't be accidentally altered.
Step 3
State the line number where iteration is first used in the algorithm shown in Figure 1.
96%
101 rated
Only available for registered users.
Sign up now to view full answer, or log in if you already have an account!
Answer
Iteration is first used in the algorithm at line 3.
Step 4
Complete the trace table for the algorithm shown in Figure 1.
98%
120 rated
Only available for registered users.
Sign up now to view full answer, or log in if you already have an account!