Question 6

AQA Computer Science June 2018 Paper 1GCSE16 marks

On the specification

6.1
3.2 Programming
6.2
3.2 Programming
6.3
3.2 Programming
6.4
3.1 Fundamentals of algorithms
6.5
3.1 Fundamentals of algorithms
6.6
3.1 Fundamentals of algorithms
6.7
3.2 Programming
Question text

6 The algorithm in Figure 2 is a sorting algorithm. • Array indexing starts at 0. • Line numbers are included but are not part of the algorithm. Figure 2 1 arr  [4, 1, 6] 2 sorted  false 3 WHILE sorted = false 4 sorted  true 5 i  0 6 WHILE i < 2 7 IF arr[i+1] < arr[i] THEN 8 t  arr[i] 9 arr[i]  arr[i+1] 10 arr[i+1]  t 11 sorted  false 12 ENDIF 13 i  i + 1 14 ENDWHILE 15 ENDWHILE 6.1 State the data type of the variable sorted in the algorithm shown in Figure 2. [1 mark] 6.2 The identifier sorted is used in the algorithm shown in Figure 2. Explain why this is a better choice than using the identifier s. [2 marks] 6.3 Shade one lozenge to show which of the following contains the false statement about the algorithm in Figure 2. [1 mark] A The algorithm uses a named constant B The algorithm uses indefinite iteration C The algorithm uses nested iteration 6.4 Complete the trace table for the algorithm shown in Figure 2. Some values have already been entered. [6 marks] arr sorted i t [0] [1] [2] 41 6 false 6.5 Fill in the values in the boxes to show how the merge part of the merge sort algorithm operates. The first and last rows have been completed for you. [3 marks] 73 4 1 2 8 5 6 12 3 4 5 6 7 8 6.6 State one advantage of the merge sort algorithm compared to the sorting algorithm in Figure 2. [1 mark] 6.7 A programmer implementing the algorithm in Figure 2 decided to create it as a subroutine. Line 1 was removed and the array arr was made a parameter of the subroutine. State two reasons why the programmer decided to implement the algorithm as a subroutine. [2 marks] Reason 1: Reason 2: