Skip to content

Instantly share code, notes, and snippets.

@piusayowale
Created August 19, 2022 12:15
Show Gist options
  • Select an option

  • Save piusayowale/c7048f7fe2ac40ea96e3276bf69efb2c to your computer and use it in GitHub Desktop.

Select an option

Save piusayowale/c7048f7fe2ac40ea96e3276bf69efb2c to your computer and use it in GitHub Desktop.
void insertionSort2(int n, vector<int> arr) {
int t, j;
for(int i = 1; i < n; i++){
t = arr[i];
for(j = i - 1; (j >= 0 && arr[j] > t); j--)
arr[j + 1] = arr[j];
arr[j + 1] = t;
for(auto ele: arr) cout<<ele<<" ";
cout<<endl;
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment