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
To identify the false statement regarding the algorithm:
A: The algorithm does not use a named constant since all values are hard-coded.
B: The algorithm does use indefinite iteration as it continues until swaps are made.
C: The algorithm utilizes nested iteration with the inner loop executing inside the outer loop.
Thus, option A is the false statement.
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, we first outline iterations:
Second iteration shows no swap needed with units unchanged. The completed trace table will capture each state of the array after the swaps made until sorted.