You are viewing a single comment's thread. Return to all comments →
C solution
int shifts = 0; for(int i = 1 ; i < arr_count ; i++){ int index = i; while(index){ if(arr[index] < arr[index-1]){ int temp = arr[index]; arr[index] = arr[index-1]; arr[index-1] = temp; shifts++; index--; } else break; } } return shifts;
Running Time of Algorithms
You are viewing a single comment's thread. Return to all comments →
C solution