insertion_sort

void insertion_sort(int *arr, int length){
    if(length <= 1)    return;

    for(int j = 1; j < length; j++){
      int key = arr[j];

      int i = j -1;
      while(i > 0 && arr[i] > key)
        arr[i + 1] = arr[i];
      arr[i + 1] = key;
    }
}

results matching ""

    No results matching ""