/*
* 希尔排序
* */
package com.yangyang.test;
public class ShellSort {
public void shellSort(Object[] r,int low,int high,int[] delth)
{
for(int k=0;k<delth.length;k++)
shellInsert(r,low,high,delth[k]);
}
private void shellInsert(Object[] r,int low,int high,int deltaK)
{
for(int i=low+deltaK;i<=high;i++)
if(strategy.compare(r[i],r[i-deltaK])<0)
{
Object temp=r[i];
int j=i-deltaK;
for(;j>=low&&strategy.compare(temp,r[j])<0;j=j-deltaK)
r[j+deltaK]=r[j];
r[j+deltaK]=temp;
}
}
}
希尔排序思路
最新推荐文章于 2022-08-20 22:20:47 发布