Created
August 19, 2022 12:15
-
-
Save piusayowale/c7048f7fe2ac40ea96e3276bf69efb2c to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| 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