We use cookies to ensure you have the best browsing experience on our website. Please read our cookie policy for more information about how we use cookies.
voidprint_arr(intarr_count,int*arr){for(inti=0;i<arr_count;i++){printf("%d ",arr[i]);}printf("\n");}voidinsertionSort1(intn,intarr_count,int*arr){if(n==1)printf("%d",arr[0]);else{for(inti=arr_count-1;i>0;i--){// from rear to frontif(arr[i]<arr[i-1]){inttemp=arr[i];// do swappingarr[i]=arr[i-1];print_arr(arr_count,arr);arr[i-1]=temp;}else{break;}}print_arr(arr_count,arr);}}
Cookie support is required to access HackerRank
Seems like cookies are disabled on this browser, please enable them to open this website
Insertion Sort - Part 1
You are viewing a single comment's thread. Return to all comments →
My solution in C: