Photo AI

The algorithm in Figure 4 is a sorting algorithm - AQA - GCSE Computer Science - Question 7 - 2021 - Paper 1

Question icon

Question 7

The-algorithm-in-Figure-4-is-a-sorting-algorithm-AQA-GCSE Computer Science-Question 7-2021-Paper 1.png

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

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

Answer

To complete the trace table, we first outline iterations:

  • Initial array: {4, 1, 6}
  • After first iteration of outer WHILE loop:
    • Compare arr[0] (4) and arr[1] (1): Swap occurs, array becomes {1, 4, 6}.
  • 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.

Join the GCSE students using SimpleStudy...

97% of Students

Report Improved Results

98% of Students

Recommend to friends

100,000+

Students Supported

1 Million+

Questions answered

;