Question 2
OCR Computer Science June 2019 Paper 2AS23 marks
On the specification
- (a)(i)
- 2.2 Problem solving and programming
- (a)(ii)
- 2.2 Problem solving and programming
- (b)(i)
- 2.2 Problem solving and programming
- (b)(ii)
- 2.2 Problem solving and programming
- (c)(i)
- 2.3 Algorithms
- (c)(ii)
- 2.2 Problem solving and programming2.3 Algorithms
- (c)(iii)
- 2.3 Algorithms
Question text
2 A procedure is shown in the following pseudocode. The arrays that are passed to the procedure store integer values. length returns the total number of elements the array can hold. 1 procedure calculateOnce(data[]:byRef, nextData[]:byRef) 2 if data.length > nextData.length then 3 loopCount = nextData.length - 1 4 else 5 loopCount = Data.length - 1 6 endif 7 count = 0 8 while count <= loopCount 9 data[count] = data[count] + nextData[count] 10 count = count + 1 11 endwhile 12 endprocedure (a) A decision is made on line 02. (i) Identify the line where the second decision is made. [1] (ii) Explain the purpose of the code in lines 02 to 06. [3] (b) The procedure has parameters passed by reference. (i) Give the identifiers of the two parameters. 1 2 [2] (ii) State the effect of the array data[] being passed by reference and not by value. [1] (c) The program needs a second procedure, sortData. It will be called taking the array data[] as a parameter by reference. The procedure will then perform a bubble sort on the data in the array. (i) Show each stage of a bubble sort on the following contents of data[]: 95 10 5 33 100 77 45 [4] (ii) Write, using pseudocode, the procedure sortData. [8] (iii) An alternative sorting method is the insertion sort. Show how an insertion sort will sort the data in the following array. 95 10 5 33 100 77 45 [4]