You are viewing a single comment's thread. Return to all comments →
int N = ar.size(); int i,j; int value; for(i=1;i<N;i++) { value=ar[i]; j=i-1; while(j>0 && value<ar[j]) { ar[j+1]=ar[j]; j=j-1; for(int k=0;k<N;k++) { printf("%d",ar[k]); printf(" "); } cout<<endl; } ar[j+1]=value; } for(j=0;j<N;j++) { printf("%d",ar[j]); printf(" "); }
Insertion Sort - Part 1
You are viewing a single comment's thread. Return to all comments →