GeezerVisonThe World Wide Web, restored to 800 pixels of glory. |
| Home|About|Gaming cabinet|Archives|How it works|Starter sites |
GeezerVison is showing github.com — leetcode/basic/sorting/ShellSort/ShellSort.java at main · zuofang/leetcode Expand file tree/ Copy pathShellSort.javaMore file actions 25 lines (21 loc) · 651 Bytes / Copy pathShellSort.javaFile metadata and controls25 lines (21 loc) · 651 Bytes 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 import java.util.Arrays; public class ShellSort { private static int[] shellSort(int[] arr) { int n = arr.length; for (int gap = n / 2; gap > 0; gap /= 2) { for (int i = gap; i < n; i++) { int key = arr[i]; int j = i; while (j >= gap && arr[j - gap] > key) { arr[j] = arr[j - gap]; j -= gap; } arr[j] = key; } } return arr; } public static void main(String[] args) { System.out.println(Arrays.toString(shellSort(new int[]{1, 2, 7, 9, 5, 8}))); } } |
| You are visitor 01402775 — GeezerVison does not store the pages you look up. Best viewed with Netscape Navigator 4.7 or Internet Explorer 6 at 800×600. No cookies required. |