Question 1
Data in a computer program needs to be sorted.
Describe the steps a bubble sort will take to sort items into ascending order.
[5]
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.
[2]
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.
[5]
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........
[2]
Identify the type of iteration used in the function partition().
[1]
Describe the role of the function partition() in the quick sort algorithm.
[3]
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........
[2]
The quick sort is an example of a divide-and-conquer algorithm.
Describe what divide-and-conquer means.
[2]