Board logo

標題: Shell Sorting [打印本頁]

作者: 白色情人    時間: 2008-10-3 22:30     標題: Shell Sorting

anyone would tell me what is shell sorting?What is "Knuth"order (以 3h+1 速度遞增)?

void Shell_sorting(int a[], int n)
{

int i, j, h, up;



for(h=1; h<=n/9; h=3*h+1)



for(; h>0; h=h/3)



for(i=h; i<n; i++)

{

up=a;

j=i;



while( j>=h && a[j-h]>up )

{

a[j]=a[j-h];

j=j-h;

}



a[j]=up;

}
}

Would anyone would explain how the three for-loops going on?
What are their purposes?
作者: arararchchch    時間: 2008-10-3 23:32

Very sorry that I am not learning C or C++ or Java...

But I am learning Pascal
作者: jayzhou_2046    時間: 2008-10-3 23:51

樓主可以先參考一下Wikipedia有關的資料:
http://en.wikipedia.org/wiki/Shell_sort




歡迎光臨 香港 Xocat Forum 討論區 (http://p.xocat.com/p/) Powered by Discuz! 6.0.0