Complete the code to start the outer loop from the second element in the array.
for i in [1]..arr.len() { // insertion sort logic }
The insertion sort starts from the second element (index 1) because the first element is considered sorted.
Complete the code to store the current element to be inserted into the sorted part.
let key = arr[[1]];The variable key holds the element at index i which we want to insert into the sorted part.
Fix the error in the while loop condition to correctly compare elements for shifting.
while j >= 0 && arr[j] [1] key { arr[j + 1] = arr[j]; j -= 1; }
The condition should check if arr[j] is greater than key to shift elements right.
Fill both blanks to correctly insert the key into its sorted position.
arr[j [1] 1] = [2];
We insert the key at position j + 1 after shifting elements.
Fill all three blanks to complete the insertion sort inner loop and update index.
let mut j = i [1] 1; while j >= 0 && arr[j] [2] key { arr[j + 1] = arr[j]; j [3] 1; }
We start j at i - 1, shift elements greater than key, and decrement j by 1 each loop.
