Selection sort performs with the same complexity to bubble sort. Its complexity is also O(n2).
Understanding selection sort
How the selection sort algorithm works
This works exactly the opposite as bubble sort, in terms of ordering the elements. Bubble sort sorts one element at every iteration and freezes its index toward the end of the collection. In contrast to that, selection sort sorts one element at every iteration and freezes its index toward the start of the collection.
You can imagine it as two subarrays, one sorted and another unsorted. In the beginning, the sorted subarray is empty and the unsorted subarray is the whole array given as input. To do this, it finds the smallest element (or the largest, if sorting in...