ExamBank Scot · AH Computing Science question bank · All AH Computing Science questions
2 marks · Insertion sort
During each iteration of an insertion sort, values in the array are compared and the position of the values may be altered. Values in array at start of sort [ 12, 7, 4, 5, 13, 6 ] Resultant array after first iteration [ 7, 12, 4, 5, 13, 6 ] Write down the resultant array after the second iteration of the insertion sort has been completed. During each pass of a bubble sort, values in the array are compared and the position of the values may be altered. Values in array at start of sort [ 12, 7, 4, 5, 13, 6 ] Resultant array after first pass [ 7, 4, 5, 12, 6, 13 ] Write down the resultant array after the second pass of the bubble sort has been completed. An integer array contains the values [ 12, 7, 4, 5, 13, 6 ]. The contents of the array are to be sorted into ascending order.
[ 4, 7, 12, 5, 13, 6 ] [ 4, 5, 7, 6, 12, 13 ]