排序算法 互动版

希尔排序算法伪代码

//希尔排序
input: an array a of length n with array elements numbered 0 to n − 1
gap ← round(n/2)
while gap > 0 do:    
    for i = gap to n − 1 do:        
        temp ← a[i]        
        j ← i        
        while j ≥ gap and a[j − gap] > temp do:            
            a[j] ← a[j − gap]            
            j ← j − gap       
        a[j] ← temp    
    gap ← round(gap / 2)
用希尔排序算法对数组arr[10] = {8, 5, 10, 12, 7, 6, 15, 9, 11, 3}从小到大排序。