daily pastebin goal
24%
SHARE
TWEET

Untitled

a guest May 16th, 2018 96 Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. public class ShellSort{
  2.  
  3.    public <DataType>[] shellSort(<DataType>[] toSort, int gap) {
  4.         if (gap < 1) {
  5.             return toSort;
  6.         }
  7.         int indSort = 0;
  8.         while (indSort + gap < toSort.length) {
  9.             int tempInd = indSort;
  10.             while (tempInd > -1 && isStrXmorethanY(toSort[tempInd], toSort[tempInd + gap])) {
  11.                 swapValues(toSort, tempInd + gap, tempInd);
  12.                 tempInd -= gap;
  13.             }
  14.             indSort += gap;
  15.  
  16.         }
  17.         gap = gap / 2;
  18.         return shellSort(toSort, gap);
  19.     }
  20.  
  21. }//O(n log(n)^2)
RAW Paste Data
Top