C++ program to sort an array of elements using selection sort
Aim:
To write a program to sort an array of elements using selection sort technique.
Algorithm:
SELECTION (A,N)
This algorithm sorts the array A with N elements.
- Repeat Steps 2 and 3 for K = 1, 2, . . . , N-1:
-
Call MIN(A, K, N, LOC).
-
[Interchange A[K] and A[LOC].]
Set TEMP : = A[K]; A[K]: = A[LOC] and A[LOC] : = TEMP.
[End of Step 1 loop]
- Exit.
Program code:
Tagged in: Algorithms, Programs