Complete the code to start the outer loop from the second element.
for (int i = [1]; i < arr.length; i++) { int key = arr[i]; int j = i - 1; while (j >= 0 && arr[j] > key) { arr[j + 1] = arr[j]; j--; } arr[j + 1] = key; }
The insertion sort starts from the second element (index 1) because the first element is considered sorted.
Complete the condition to move elements greater than the key to the right.
while (j >= 0 && arr[j] [1] key) { arr[j + 1] = arr[j]; j--; }
We move elements that are greater than the key to the right to make space for the key.
Fix the error in placing the key after shifting elements.
arr[[1]] = key;After shifting elements, the key should be placed at index j + 1.
Fill both blanks to complete the inner loop condition and decrement.
while ([1] >= 0 && arr[[1]] > key) { arr[[1] + 1] = arr[[1]]; [2]; }
The inner loop uses 'j' to check and shift elements, and 'j--' to move left.
Fill all three blanks to create a map from each index to its element if greater than 0.
Map<Integer, Integer> sortedPositions = new HashMap<>(); for (int i = 0; i < arr.length; i++) { if (arr[i] [1] 0) { sortedPositions.put([2], [3]); } }
We check if element is greater than 0, then map index i to element arr[i].
