排序算法 互动版

在线工具推荐: Three.js AI纹理开发包 - YOLO合成数据生成器 - GLTF/GLB在线编辑 - 3D模型格式在线转换 - 可编程3D场景编辑器

希尔排序算法伪代码

//希尔排序
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}从小到大排序。