Algorithms and programming June 2025, Question 1 22 marks
Data in a computer program needs to be sorted.
Describe the steps a bubble sort will take to sort items into ascending order.
Reveal mark scheme
Darcie and Felix have both written a program that will perform a bubble sort to put these numbers into ascending order.
Darcie’s version will complete six passes. However, Felix’s version will only need to complete two passes.
Explain how Felix may have made his version more efficient than Darcie’s version.
Reveal mark scheme
A second type of sorting algorithm is an insertion sort.
Describe how an insertion sort can be used to put the following data into ascending order.
Reveal mark scheme
A third type of sorting algorithm is a quick sort.
The following quick sort algorithm is made up of two functions called partition() and quickSort(). The algorithm will sort an integer array into ascending numerical order.
Identify which of the two functions is recursive and give all of the line numbers where recursive calls are made.
Recursive function name........
Recursive call line numbers........
Reveal mark scheme
Identify the type of iteration used in the function partition().
Reveal mark scheme
Describe the role of the function partition() in the quick sort algorithm.
Reveal mark scheme
The algorithm needs to be changed to sort the integer array into descending numerical order.
Identify the line number that needs to be changed and write the amended line of code.
Amended line of code........
Reveal mark scheme
The quick sort is an example of a divide-and-conquer algorithm.
Describe what divide-and-conquer means.
Reveal mark scheme