Created
October 13, 2021 17:53
-
-
Save maxgoren/54a14d25f22af6756c5cc108262505d1 to your computer and use it in GitHub Desktop.
This file contains 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
template <typename T> | |
void shellSort(vector<T>& arr) | |
{ | |
int N = arr.size(); | |
for (int gap = N/2; gap > 0; gap /= 2) | |
{ | |
for (int i = gap; i < N; i += 1) | |
{ | |
int temp = arr[i]; | |
int j; | |
for (j = i; j >= gap && arr[j - gap] > temp; j -= gap) | |
{ | |
arr[j] = arr[j - gap]; | |
} | |
arr[j] = temp; | |
} | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment