希尔排序 ShellSort Java代码
来源:互联网 发布:linux 重新挂载根目录 编辑:程序博客网 时间:2024/06/14 10:37
public class ShellSort {public static void main(String[] args) {int[] num = {3,2,1,5,4,2,8,6,12,2};shellSort(num);for(int i : num){System.out.println(i);}}public static void shellSort(int[] data){int h = 1;//缩小增量while(h<=data.length/3){h = h*3+1;}while(h > 0){for(int i = h; i < data.length; i++){if(data[i] < data[i - h]){//需要插入int temp = data[i];int j = i -h;for(;j >= 0 && data[j] > temp; j-=h){data[j + h] = data[j];//在插入之前,整体后移}data[j + h] = temp;//插入}}h = (h - 1) / 3;}}public static void swap(int[] data, int i, int j){int temp = data[i];data[i] = data[j];data[j] = temp;}}
0 0
- 希尔排序 ShellSort Java代码
- java希尔排序--ShellSort
- 希尔排序-shellSort java实现
- Java排序算法--希尔排序(Shellsort)
- 排序- 希尔排序 ShellSort
- 希尔排序(shellsort)
- 希尔排序算法 shellsort
- 希尔排序(ShellSort)
- 希尔排序shellsort
- 希尔排序 (ShellSort)
- uva10152-shellsort && 希尔排序
- 希尔排序(Shellsort)
- 希尔排序(ShellSort)
- 【ShellSort】希尔排序
- 希尔排序---shellsort
- 希尔排序(ShellSort)
- 希尔排序(shellsort)
- 希尔排序 ShellSort
- Filter/Listener简介
- 知识体系
- 【一天一道LeetCode】#97. Interleaving String
- Unity Editor编程杂记
- springmvc注解开发-商品修改功能分析
- 希尔排序 ShellSort Java代码
- AWR的使用
- spring mvc 集成 swagger及swagger ui
- Swift-Charts 多种样式图表-详细
- android滑动冲突的解决方案
- 编程之美2.11寻找最近的点对Java版二
- ADDM的使用
- https原理简述
- Cocoa/Cocoa Touch