The challenge question asks how many instructions are needed for the implementation of the insertion sort algorithm shown below. It asks what is the best case scenario for a length 5 array when the array is already in sorted order? Correct answer according to the official solution is 32. However, it is not clear whether this should take into account short-circuit evaluation of the “and” operator.
for (int i = 0; i < input.length; i++) { int key = input[i]; j = i - 1; while (j >= 0 && input[j] > key) { if (input[j] > key) { int tmp = input[j]; input[j] = key; input[j + 1] = tmp; j--; } } }