My issue
explain my error what i need to do
My code
def selectionSort(arr):
for i in range(len(arr)):
# Assume the current index holds the smallest element
min_index = i
# Find the index of the smallest element in the remaining array
for j in range(i + 1, len(arr)):
if arr[j] < arr[min_index]:
min_index = j
# Swap the smallest element found with the element at the current index
arr[i], arr[min_index] = arr[min_index], arr[i]
return arr
# Input
n = int(input())
arr = list(map(int, input().split()))
# Perform Selection Sort
sorted_arr = selectionSort(arr)
# Output the sorted array
print(" ".join(map(str, sorted_arr)))
Learning course: Data structures & Algorithms lab
Problem Link: Complete the implementation in Data structures & Algorithms lab