Question 6
OCR Computer Science June 2024 Algorithms and programming (H446-02)A level15 marks
On the specification
- (a)
- 2.3 Algorithms
- (b)
- 2.3 Algorithms
- (c)
- 2.3 Algorithms
- (d)(i)
- 2.3 Algorithms
- (d)(ii)
- 2.3 Algorithms
- (d)(iii)
- 2.3 Algorithms
- (d)(iv)
- 2.3 Algorithms
Question text
6 The following strings are stored in an array. "rainbow" "moon" "sun" "stars" "clouds" "tornado" (a) Explain how a linear search would search the array for the index that stores "clouds". [3] (b) State why a binary search cannot be used in this example. [1] (c) Show how an insertion sort will sort the given data into ascending alphabetical order. "rainbow" "moon" "sun" "stars" "clouds" "tornado" [5] (d) (i) A sorting algorithm has a best time complexity of O(n). Describe what is meant by the best time complexity O(n) for a sorting algorithm. [2] (ii) Another sorting algorithm has a worst space complexity of O(log(n)). Describe what is meant by the worst space complexity O(log(n)) for a sorting algorithm. [2] (iii) Identify the time complexity that means the time will not change even when the number of items increases. [1] (iv) Identify the space complexity that means the amount of memory (space) used will double each time a new item is included. [1]