The algorithm in Figure 4 is a sorting algorithm - AQA - GCSE Computer Science - Question 7 - 2021 - Paper 1
Question 7
The algorithm in Figure 4 is a sorting algorithm.
Array indexing starts at 0.
Line numbers are included but are not part of the algorithm.
Figure 4
arr <- {4, 1,... show full transcript
Worked Solution & Example Answer:The algorithm in Figure 4 is a sorting algorithm - AQA - GCSE Computer Science - Question 7 - 2021 - Paper 1
Step 1
State the data type of the variable swapsMade in the algorithm shown in Figure 4.
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 data type of the variable swapsMade in the algorithm is Boolean (or bool). This indicates that swapsMade can hold one of two possible values: true or false.
Step 2
Explain why this is a better choice than using the identifier s.
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
Using the identifier swapsMade is preferable to s because it clearly describes the purpose of the variable. The name provides a meaningful context that makes the algorithm easier to understand and maintain. In contrast, s is vague and does not convey the variable's role, making the code harder to read and follow.
Step 3
Shade one lozenge to show which of the following contains the false statement about the algorithm in Figure 4.
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
B The algorithm uses indefinite iteration.
Step 4
Complete the trace table for the algorithm shown in Figure 4. Some values have already been entered.
98%
120 rated
Only available for registered users.
Sign up now to view full answer, or log in if you already have an account!
Answer
arr
swapsMade
i
t
[0]
1
0
4
4 1 6
false
true
1 4 6
false
true
Step 5
Complete the trace table for the algorithm shown in Figure 4. Some values have already been entered.
97%
117 rated
Only available for registered users.
Sign up now to view full answer, or log in if you already have an account!