Hide text Hide pseudo-code | |
Apply insertion sort to the Input table below. You can simulate the algorithm by performing all the necessary assignment operations in code lines 2, 5 and 7. In order to assign, for example, the value in array position 1 into the tmp variable (tmp = a[1]), drag and drop the corresponding value from Input on top of the tmp beneath the array. | |
InsertionSort(a) 1 for i = 1 to n-1 do 2 tmp = a[i] 3 j = i 4 while j > 0 AND a[j-1] > tmp do 5 a[j] = a[j-1] 6 j = j - 1 7 a[j] = tmp |