Complete the code to start the outer loop for selection sort.
for i := 0; i < [1]; i++ { // find the minimum element in unsorted array }
The outer loop runs from 0 to length of array minus 1 because the last element will be sorted by then.
Complete the code to start the inner loop to find the minimum element.
minIndex := i for j := i + 1; j < [1]; j++ { if arr[j] < arr[minIndex] { minIndex = j } }
The inner loop runs from i+1 to the end of the array to find the minimum element in the unsorted part.
Fix the error in swapping elements after finding the minimum index.
temp := arr[i]
arr[i] = arr[[1]]
arr[minIndex] = tempWe swap arr[i] with arr[minIndex] to place the minimum element at the correct position.
Fill both blanks to complete the selection sort function header and return statement.
func [1](arr []int) []int { // sorting logic here return [2] }
The function is named SelectionSort and returns the sorted array 'arr'.
Fill all three blanks to complete the selection sort main logic inside the function.
for i := 0; i < [1]; i++ { minIndex := i for j := i + 1; j < [2]; j++ { if arr[j] < arr[[3]] { minIndex = j } } arr[i], arr[minIndex] = arr[minIndex], arr[i] }
The outer loop runs to len(arr)-1, inner loop to len(arr), and comparison uses minIndex to find the smallest element.