Selection sort using Python

Selection sort:

Thiru Malai
Jun 6, 2021

The selection sort algorithm sorts an array by repeatedly finding the minimum element (considering ascending order) from unsorted part and putting it at the beginning. The algorithm maintains two subarrays in a given array. ) The subarray which is already sorted.

Set the first element as minimum and find the other numbers minimun than the first number.

When the number is minimum than all the number .Then that number is considered as a sorted.

Swap Method:

temp=nums[i]

nums[i]=nums[minpos]

nums[minpos]=temp

The above code works as a swapping method.That the minimum number swap to the minpos.

Code:

Step by Step execution:

Output:

Refer GUVI

--

--