Selection Sort
Selection Sort
#include <iostream>
int minIndex = i;
minIndex = j;
if (minIndex != i) {
arr[i] = arr[minIndex];
arr[minIndex] = temp;
int main() {
int n;
cin >> n;
int arr[n];
cout << "Enter " << n << " elements:" << endl;
selectionSort(arr, n);
1. Start.
o Set minIndex = i.
6. End.
PSEUDOCODE:::
Function SelectionSort(array, n)
For i = 0 to n-2
minIndex = i
minIndex = j
EndIf
EndFor
If minIndex != i
Swap(array[i], array[minIndex])
EndIf
EndFor
EndFunction
Main
Input n
Declare array[n]
For i = 0 to n-1
Input array[i]
EndFor
Call SelectionSort(array, n)
For i = 0 to n-1
Print array[i]
EndFor
EndMain