You are viewing a single comment's thread. Return to all comments →
My solution in C:
void swap(int* a, int* b){ *a ^= *b; *b ^= *a; *a ^= *b; } int runningTime(int arr_count, int* arr) { int res = 0; for (int i = 1; i<arr_count; i++){ for (int j = i-1; j >= 0; j--){ if (arr[j] > arr[j+1]){ swap(&arr[j], &arr[j+1]); res ++; } else break; } } return res; }
Seems like cookies are disabled on this browser, please enable them to open this website
Running Time of Algorithms
You are viewing a single comment's thread. Return to all comments →
My solution in C: