Selection Sort in list Program in Python

Python
Python


Code:

nums=[6,7,5,4,8,3,567,456,46,43,542,5,4525,65,6,3677,3,676,32,7]
n=len(nums)
for i in range(n):
    minpos=i
    for j in range(i,n):
        if nums[minpos] > nums[j]:
            minpos = j
    nums[i],nums[minpos]=nums[minpos],nums[i]
print(nums)

Output:

[3, 3, 4, 5, 5, 6, 6, 7, 7, 8, 32, 43, 46, 65, 456, 542, 567, 676, 3677, 4525]
>>> 


Tags: 
selection sort,python,python selection sort,selection sort algorithm,selection sort in python,selection sort python,selection sort in c,insertion sort,selection sort algorithm python,selection sort python tutorial,selection sort code,sorting algorithms in python,python selection sort algorithm,python programming,selection sort algorithm in python,algorithms in python,python programs,selection sort python program

Post a Comment

Previous Post Next Post