This program is written in C language and implements the Selection Sort algorithm to sort an array of 5 integers in ascending order. The program initializes an unsorted array of integers and calls the Selection Sort function to sort the array in place. The program then outputs the sorted array.
- Initialize an unsorted array of n elements.
- Repeat the following process for i = 0 to n-1:
a. Set the minimum element index to i.
b. Repeat the following process for j = i+1 to n:
c. If the element at index j is less than the element at the minimum index, then set the minimum index to j.
d. If the minimum index is not equal to i, then swap the elements at index i and the minimum index. - The array is now sorted in ascending order.
- Selection Sort is simple to implement and understand, making it a good choice for small arrays.
- Selection Sort is efficient for small arrays, particularly when the number of swaps is a concern.
The program demonstrates how to use the Selection Sort algorithm to sort an array of integers in ascending order.