How to program for selection sort python.
- def selectionsort(a,n):for i in range(0,n):small=a[i]place=ifor j in range(i+1,n):if small>a[j]:small=a[j]place=jif place!=i:a[place]=a[i]a[i]=smallarray=[]n=int(input("Enter the size of the array"))print("Enter the array")for x in range(n):x=int(input())array.append(x)selectionsort(array,n)print ("Sorted array is:")for i in range(n):print(array[i])
0 Comments