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
1 arr <... 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
Shade one lozenge to show which of the following contains the false statement about the algorithm 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 false statement is:
A The algorithm uses a named constant.
The algorithm does not use any named constants since it only utilizes variables like 'arr' and 'swapsMade' throughout.
Step 2
Complete the trace table for the algorithm shown in Figure 4.
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
To complete the trace table for the algorithm, we will keep track of the array 'arr' and the variable 'swapsMade' at each iteration.
Here's an example of how the trace would look:
Iteration
arr
swapsMade
i
0
{4, 1, 6}
false
0
1
{1, 4, 6}
false
0
2
{1, 4, 6}
false
1
The process will continue until no swaps are made in an iteration.