Algorithm-Sort-Insert-ShellSort01-Java-希尔排序

ShellSort

public static void shellSort(int[] array) {
    	int tmp,i,j,group;
    	int step = array.length;
    	for(step = step/2;step >= 1;step=step/2) {
    		for(group = 0;group <= step-1;group++) { 
    			for( i = group+step;i <= array.length -1;i = i+step) { 
    				tmp = array[i];
    				for(j = i-step;j >= 0;j = j-step) { 
    					if(array[j] > tmp) {
    						array[j+step] = array[j];
    					}else {
    						break;
    					}
    				}
    				array[j+step] = tmp;
    			}
    		}
    	}
    }

Algorithm-Sort-Insert-ShellSort01-Java-希尔排序_第1张图片

待改进1:排序分析、时间复杂度和空间复杂度分析
待改进2:排序GIF图

小白发文,有错及不足请指出,嘻嘻?~~~,Learning on the way~~~

你可能感兴趣的:(Algorithm-Sort,Java-Java基础,Algorithm,Sort,Insert,ShellSort,希尔排序)