OCR 2023 COMPUTER SCIENCE H046/02: ALGORITHMS AND PROBLEM SOLVING AS LEVEL QUESTION PAPER & MARK SCHEME (MERGED)
A program uses a bubble sort to sort data into ascending numerical order. The data is stored in a 0-indexed 1-dimensional array. (a) Show each stage of a bubble sort to sort this data into ascending numerical order: 1 5 3 9 2 7 You should clearly show and label each pass in your answer. ................................................................................................................................................... ................................................................................................................................................... ................................................................................................................................................... ................................................................................................................................................... ................................................................................................................................................... ................................................................................................................................................... ................................................................................................................................................... ................................................................................................................................................... ................................................................................................................................................... ................................................................................................................................................... ................................................................................................................................................... ................................................................................................................................................... ................................................................................................................................................... ................................................................................................................................................... ................................................................................................................................................... ................................................................................................................................................... ................................................................................................................................................... ................................................................................................................................................... ...........................................................................................................................................[4] 5 Turn over (b) A programmer has partially developed a bubble sort algorithm in pseudocode. This will partially sort an array of numbers called numbers that is passed as a parameter. 01 procedure bubbleSort(numbers : byRef) 02 flag = true 03 for x = 0 to h – 1 04 if numbers[x] > numbers[x + 1] then 05 holdValue = numbers[x] 06 numbers[x] = numbers[x + 1] 07 numbers[x + 1] = holdValue 08 flag = false 09 endif 10 next x 11 endprocedure (i) Explain why the procedure bubbleSort accepts the array numbers by reference and not by value. ........................................................................................................................................... ........................................................................................................................................... ........................................................................................................................................... ........................................................................................................................................... ........................................................................................................................................... . ..................................................................................................................................[3] (ii) The programmer has used a for loop on line 3 in the procedure bubbleSort. A for loop is a count controlled loop. State what is meant by the term ‘count controlled loop
Written for
- Institution
- Graduation in computer science
- Course
- Graduation in computer science
Document information
- Uploaded on
- May 9, 2024
- Number of pages
- 42
- Written in
- 2023/2024
- Type
- Exam (elaborations)
- Contains
- Questions & answers
Subjects
-
ocr 2023 computer science h04602 algorithms and
Also available in package deal