Created
April 12, 2021 11:32
-
-
Save ButlerFuqua/cddb7be5c459f7ece4bf47d235a7f1d7 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
InsertionSortInterleaved(numbers, numbersSize, startIndex, gap) { | |
i = 0 | |
j = 0 | |
temp = 0 // Temporary variable for swap | |
for (i = startIndex + gap; i < numbersSize; i = i + gap) { | |
j = i | |
while (j - gap >= startIndex && numbers[j] < numbers[j - gap]) { | |
temp = numbers[j] | |
numbers[j] = numbers[j - gap] | |
numbers[j - gap] = temp | |
j = j - gap | |
} | |
} | |
} | |
ShellSort(numbers, numbersSize, gapValues) { | |
for each (gapValue in gapValues) { | |
for (i = 0; i < gapValue; i++) { | |
InsertionSortInterleaved(numbers, numbersSize, i, gapValue) | |
} | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment