Guest User

Untitled

a guest
May 16th, 2018
178
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.57 KB | None | 0 0
  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)
Add Comment
Please, Sign In to add comment