Embed presentation
Downloaded 61 times





![Program
6
for(i=0; i< n-1; i++)
{
/* find the index of min element in the unsorted a[j ..
n-1] assume the min is the first element */
minIndex=i;
// test against elements after j to find the smallest
for(j=i+1; j< n; j++)
{
// if this element is less, then it is the new minimum
if(A[j] < A[minIndex])
minIndex = j;
}
/* iMin is the index of the minimum element. Swap it
with the current position */
if(minIndex!=i)
{
temp = A[i];
A[i]=A[minIndex];
A[minIndex] = temp;
}
}](https://image.slidesharecdn.com/selectionsortrv-160528194412/85/Selection-Sort-Vipin-Ramola-6-320.jpg)





This document provides an overview of selection sort, including its objectives, previous knowledge required, algorithm, program, animation, applications, and advantages/disadvantages. Selection sort works by iterating through an array and swapping the smallest remaining element into the sorted portion of the array. It is useful for sorting small arrays or when memory is limited, but performs more slowly as the number of elements increases compared to other sorting algorithms.





![Program
6
for(i=0; i< n-1; i++)
{
/* find the index of min element in the unsorted a[j ..
n-1] assume the min is the first element */
minIndex=i;
// test against elements after j to find the smallest
for(j=i+1; j< n; j++)
{
// if this element is less, then it is the new minimum
if(A[j] < A[minIndex])
minIndex = j;
}
/* iMin is the index of the minimum element. Swap it
with the current position */
if(minIndex!=i)
{
temp = A[i];
A[i]=A[minIndex];
A[minIndex] = temp;
}
}](https://image.slidesharecdn.com/selectionsortrv-160528194412/85/Selection-Sort-Vipin-Ramola-6-320.jpg)



