Algorithm: Selection Sort
Goal: Sort an array of numbers in ascending order using the Selection Sort technique.
Steps:
- Start
- Input
n(number of elements in the array). - Input the array
arr[0…n-1]. - For
i = 0ton-2:- Set
minIndex = i. - For
j = i+1ton-1:- If
arr[j] < arr[minIndex]:- Set
minIndex = j.
- Set
- If
- If
minIndex != i:- Swap
arr[i]andarr[minIndex].
- Swap
- Set
- Print the sorted array.
- Stop
Flowchart: Selection Sort

Post Comment