Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- public class ShellSort{
- public <DataType>[] shellSort(<DataType>[] toSort, int gap) {
- if (gap < 1) {
- return toSort;
- }
- int indSort = 0;
- while (indSort + gap < toSort.length) {
- int tempInd = indSort;
- while (tempInd > -1 && isStrXmorethanY(toSort[tempInd], toSort[tempInd + gap])) {
- swapValues(toSort, tempInd + gap, tempInd);
- tempInd -= gap;
- }
- indSort += gap;
- }
- gap = gap / 2;
- return shellSort(toSort, gap);
- }
- }//O(n log(n)^2)
Add Comment
Please, Sign In to add comment