Which term describes an algorithm that puts a list of items into order by comparing each neighbouring pair in turn, swapping them when they are in the wrong order, and repeating until a complete run makes no swaps?
Bubble sort
What is meant by 'merge sort'?
A sorting algorithm that repeatedly divides a list into smaller sub-lists until each holds one item, then combines them back together in order
What is meant by 'insertion sort'?
A sorting algorithm that takes each item in turn and inserts it into its correct position among the items already sorted, shifting larger items one place to the right
What is the name for a single complete run through a list in which every neighbouring pair of items is compared once?
A pass
Which term describes arranging the items of a list so that the smallest value comes first and the largest value comes last?
Ascending order
What is meant by a swap in a sorting algorithm?
Two items change places in the list
What is meant by a sub-list in a merge sort?
A smaller list made by dividing the original list into parts
When does a bubble sort know that the list has been sorted?
After a whole pass is made with no swaps
The list 5, 3, 8, 1 is sorted into ascending order with a bubble sort. What is the list after the first pass?
3, 5, 1, 8
In the code for a bubble sort, what is the swapped flag used for?
It shows that a pass made no swaps so the sort stops
In a merge sort, what is done to the list before the merging begins?
It is split until every sub-list holds one item
The list 6, 2, 5, 1 is sorted with a merge sort. What are the sub-lists after the first merging step?
2, 6 and 1, 5
The list 9, 4, 7, 2 is sorted into ascending order with an insertion sort. What is the list once 7 has been inserted?
4, 7, 9, 2
Which statement about the three standard sorting algorithms is correct?
Merge sort is usually quicker on large lists but needs extra memory
During the merge step of a merge sort, which item is copied into the result list next?
The smaller of the two front items is copied next
A programmer wants to sort an unsorted list of numbers using one of the three standard sorting algorithms. What has to be done to the list before the sort can start?
Nothing, the sort can start with the items in any order
Which sorting algorithm does this code use?
Insertion sort
The list 4, 9, 1, 6 is sorted into descending order using a bubble sort. What is the list after the first pass?
9, 4, 6, 1
Why does a bubble sort finish quickly when a list is already nearly in order?
Only a few passes are needed before one makes no swaps
During the merge of two sorted lists, one list runs out of items before the other. What happens to the items that are left?
They are copied straight to the end of the result list
After the first pass of a bubble sort that is putting a list into ascending order, which item is certain to be in its final position?
The largest item, at the end of the list
The words pear, apple, lemon, banana are sorted into ascending alphabetical order using an insertion sort. What is the list once lemon has been inserted?
Apple, lemon, pear, banana
What is meant by a pre-requisite of an algorithm?
A condition that must already be true before the algorithm can be used
Which sorting algorithm does this code use?
Bubble sort
Which sorting algorithm uses this code?
Merge sort
We use cookies to enhance your experience. You can manage your preferences or learn more in our Cookie Policy.