希尔排序算法

public void ShellSort(int[] array)
{
   
int i,j,increment,temp;
   
for(increment = array.Length/2; increment>0; increment/=2)
   {
       
for(i = increment; i<array.Length; i++)
       {
           temp 
= array[i];
           
for(j=i; j>=increment; j-=increment)
           {
               
if(temp<array[j-increment])
               {
                  array[j] 
= array[j-increment];
               }
               
else
                  
break;
           }
           array[j] 
= temp;
       }
   }
}

 

posted @ 2010-03-15 01:53  goldkevin  阅读(129)  评论(0编辑  收藏  举报