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 he... 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 for the variable seconds is Integer/int. This is because seconds is counting the total time in seconds, which cannot be a fractional value.
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
The variable rest could have been defined as a constant because its value is not expected to change during the execution of the algorithm. Since it is used consistently for comparisons without modification, declaring it as a constant aids in clarity and prevents accidental changes.
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!