Complete the code to start the outer loop from the second element in the array.
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 assigning the key to its correct position after shifting.
arr[[1]] = key;After shifting elements, the key should be placed at index j + 1.
Fill both blanks to complete the insertion sort outer and inner loops correctly.
for (int [1] = 1; [1] < arr.Length; [1]++) { int key = arr[[2]]; int j = [2] - 1; while (j >= 0 && arr[j] > key) { arr[j + 1] = arr[j]; j--; } arr[j + 1] = key; }
The outer loop variable is commonly 'i' and must be consistent in the loop and key assignment.
Fill all three blanks to create a dictionary comprehension that maps each element to its sorted position if greater than 2.
var result = new Dictionary<int, int>()
{
{ [1], [2] } for (int [3] = 0; [3] < arr.Length; [3]++)
if (arr[[3]] > 2)
};The dictionary maps index ({{BLANK_3}}) to the element value (arr[{{BLANK_3}}]) for elements greater than 2.
