Selection Sort Algorithm
Selection Sort Algorithm
Selection Sort is a simple sorting algorithm that divides the array into two parts:
Sorted portion: Initially empty and grows as elements are placed in order.
Unsorted portion: Shrinks as the smallest element is selected and moved to the
sorted portion.
Explanation
Outer loop: Iterates over each position in the array.
Inner loop: Finds the index of the smallest element in the unsorted portion of the
array.
Swap: The smallest element is swapped with the current element at position i.
Example
Input: [64, 25, 12, 22, 11]
Step-by-Step Process: