希尔排序
来源:互联网 发布:站长工具 网站数据 编辑:程序博客网 时间:2024/06/05 00:25
package sun;public class Sort {/** * * @param 待排序数组 * */public static void shell(int[] a, int l, int r) {int h;for (h = l; h <= (r - l) / 9; h = 3 * h + 1);for (; h > 0; h /= 3) {for (int i = l + h; i <= r; i++) {int j = i;int v = a[i];while (j >= l + h && v < a[j - h]) {a[j] = a[j - h];j -= h;}a[j] = v;}}}public static void main(String[] args) {int[] arr = { 49, 38, 65, 97, 76, 13, 27, 49 };shell(arr, 0, arr.length - 1);for (int a : arr)System.out.println(a);}}
0 0
- 希尔排序
- 希尔排序
- 希尔排序
- 希尔排序
- 希尔排序
- 希尔排序
- 希尔排序
- 希尔排序
- 希尔排序
- 希尔排序
- 希尔排序
- 希尔排序
- 希尔排序
- 希尔排序
- 希尔排序
- 希尔排序
- 希尔排序
- 希尔排序
- 手把手教你使用Git
- oracle 3 死锁处理
- Guava类库学习--Multiset+Multimap+BiMap
- 第9周项目2592: 改错题B--数组元素交换
- Greatest Common Divisor (GCD) - Euclidean algorithm
- 希尔排序
- 翻转单词顺序VS左旋转字符串
- 谈谈布隆过滤器(比哈希表省很多内存,简言之更牛逼)
- hdu 2191 悼念512汶川大地震遇难同胞——珍惜现在,感恩生活
- 图片渲染的应用
- OpenCV 实现HOG行人检测
- Python, MySQLdb 编码问题 UnicodeEncodeError:'latin-1' codec can't encode character ...
- String之 split 分割字符串(分隔符如:* ^ : | , .) 及注意点
- Samza状态管理分析