EmbLogic's Blog

problem in insertion sort….. what is the problem??

#include

int insertion_sort(int *a,int elem)
{
int temp=0,temp2=0,max=0,i=0,j=0;
for(i=0;i<elem-1;i++)
{
temp=*(a+i+1);
for(j=i;temp0;j–) *(a+j+1)=*(a+j);
*(a+j)=temp;
}
printf(“sorting done…”);
return 0;
}

int main()
{
int a[]={10,9,8,7,6,5,4,3,2,1},i=0;
insertion_sort(a,10);
for(i=0;i<=10;i++) printf("%d\n",*(a+i));
return 0;
}

One Response to problem in insertion sort….. what is the problem??

  1. msiddarth says:

    print the issue where you are facing????

Leave a Reply

Your email address will not be published. Required fields are marked *

You may use these HTML tags and attributes: <a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <strike> <strong>