摘要:
Shell排序算法是D.L.Shell 于1959年发明的。其基本思想是:先比较距离远的元素,而不是简单交换排序算法那样先比较相邻的元素。这样可以快速减少大量的无序情况,从而减轻后续的工作。被比较的元素之间的距离逐步减少,直到减少为1,这时排序变成了相邻元素的互换。/*shellsort:sort v[0]...v[n-1] into increasing order*/#include<stdio.h>void shellsort(int v[],int n){int gap,i,j,temp;for(gap=n/2;gap>0;gap/=2)for(i=gap;i< 阅读全文
posted @ 2011-12-06 19:09
四月不留
阅读(404)
评论(0)
推荐(0)