human
Difference between Insertion sort and Selection sort | Function to implement the selection sort.
One by one move boundary of unsorted subarray.
Find the minimum element in unsorted array.
Swap the found minimum element with the first element.
Function to print an array.
Driver Code.
Function Call.
Print the array"
How can the above be solved in Python?
 ... What is a code to difference between Insertion sort and Selection sort and the other steps required?
assistant
#Here is code to difference between Insertion sort and Selection sort and the other steps required.
 def selectionSort ( arr , n ) :
	for i in range ( n - 1 ) :
		min_idx = i
		for j in range ( i + 1 , n ) :
			if ( arr [ j ] < arr [ min_idx ] ) :
				min_idx = j
		arr [ min_idx ] , arr [ i ] = arr [ i ] , arr [ min_idx ]
def printArray ( arr , size ) :
	for i in range ( size ) :
		print ( arr [ i ] , end = " ▁ " )
	print ( )
if __name__ == " _ _ main _ _ " :
	arr = [ 64 , 25 , 12 , 22 , 11 ]
	n = len ( arr )
	selectionSort ( arr , n )
	print ( " Sorted ▁ array : ▁ " )
	printArray ( arr , n )