In this article, we shall learn about the selection sorting algorithm in Python. Selection sorting is an algorithm that sorts a given array by repeatedly searching for the smallest/largest element (depending upon the order of sorting) in an unsorted portion of the array, and then placing the found element at the start.
- The concept of selection sorting.
- Implementing selection sort in Python.
- Time complexity of selection sort.
- Space complexity of selection sort.
The selection sort algorithm operates by maintaining a partition of the given array into the following two arrays, at any point:
- The subarray which is already sorted.
- The remaining subarray, which has yet not been sorted.
In each of its iterations, the selection sort finds the smallest/largest element in the unsorted subarray and moves it to the sorted subarray.
Image Courtesy: technologystrive