Selection Sort program in C Language algorithm implementation – selection sort is it never makes more than O(n) swaps and can be useful when memory write is a costly operation.
- Time Complexity: O(n2)
- Auxiliary Space: O(1)
In this program user would be asked to enter the number of elements along with the element values and then the programs would sort them in ascending order by using merge sorting algorithm logic.
Types of Sorting Algorithms:

Selection Sort algorithm C Program implementation
#include <stdio.h>
int main() {
int arr[10]={5,11,1,19,12,100,56,46,35,3};
int n=10;
int i, j, position, swap;
for (i = 0; i < (n - 1); i++) {
position = i;
for (j = i + 1; j < n; j++) {
if (arr[position] > arr[j])
position = j;
}
if (position != i) {
swap = arr[i];
arr[i] = arr[position];
arr[position] = swap;
}
}
for (i = 0; i < n; i++)
printf("%d\t", arr[i]);
return 0;
}
OUTPUT
1 3 7 12 13 19 35 46 56 100
Additional Reading
- SEO Practices Everyone Should Follow SEO Rules
- Complete Top SEO Checklist
- Yoast Seo Premium 15.2 Nulled – WordPress SEO Plugin
- Top 50+ SEO Interview Questions
- What is a Backlink? How to Get More Backlinks
- TCS INTERVIEW QUESTIONS
- Top 20 Python Project Ideas
- Top 50 Python Project with Source Code
- Top 20 Android Project with Source Code
- Top 20 Interview Programs
- Top 20 Company Interview Questions
you can read more articles like this here.
READ MORE
If you found this post useful, don’t forget to share this with your friends, and if you have any query feel free to comment it in the comment section.❤