• Now Online : 44
  • admin@codemyne.net


Selection sort: Selection sort is also called as push-down sorting. As the name suggests, the first element of the list is selected and compared repeatedly with each and every element up to last. If any element is found to be lesser than the selected element, these two are swapped. This procedure is repeated till the entire array is sorted. It is slow and not very intelligent, because it compares with each and every one.

    #include <stdio.h>
    void sel(int *,int);
    void main()
        int size =5,z;
        int arr[5];
        printf("enter the data to be sorted : ");
        for (z =0;z <5 ;z++ )
        void sel(int *a,int s)
            int temp,i,j,min;
            for (i =0;i < s-1 ;i++ )
                min = i;
                for (j= i+1;j<s ;j++ )
                    if (*(a+j) < *(a+min))
                    min =j;
                temp = *(a+min);
                *(a+min) = *(a+i);
                *(a+i) = temp;
            printf("the sorted data:");
            for (i=0;i < s ;i++ )

Comments/Suggestions are invited. Happy coding......!

Comments Post a Comment