Question 6
AQA Computer Science November 2021 Paper 1 (8520/1)GCSE11 marks
On the specification
- 6.1
- 3.1 Fundamentals of algorithms
- 6.2
- 3.1 Fundamentals of algorithms
- 6.3
- 3.1 Fundamentals of algorithms
- 6.4
- 3.1 Fundamentals of algorithms3.2 Programming
Question text
6 1 box . State the comparisons that would be made when the linear search algorithm is used to search for the value 8 in the following array (array indices have been included above the array). 1 2 3 4 5 6 47 8 13 14 15 17 [3 marks] 6.2 State the comparisons that would be made when the binary search algorithm is used to search for the value 8 in the following array (array indices have been included above the array). 1 2 3 4 5 6 47 8 13 14 15 17 [3 marks] 6.3 State why binary search is considered a better algorithm than linear search. [1 mark] 6.4 The algorithm in Figure 5 is a new search algorithm. box Figure 5 arr ← [3, 4, 6, 7, 11, 14, 17, 18, 34, 42] value ← 21 found ← False finished ← False i ← 0 down ← False WHILE (found = False) AND (finished = False) IF arr[i] = value THEN found ← True ELSE IF arr[i] > value THEN down ← True i ← i – 1 ELSE IF (arr[i] < value) AND (down = True) THEN finished ← True ELSE i ← i + 4 ENDIF ENDIF ENDIF ENDWHILE Complete the trace table for the algorithm in Figure 5. The first row has been completed for you. You may not need to use all rows of the trace table. [4 marks] found finished i down False False 0 False