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.js at main · controltable/leetcode Expand file tree/ Copy pathShellSort.jsMore file actions 21 lines (19 loc) · 528 Bytes / Copy pathShellSort.jsFile metadata and controls21 lines (19 loc) · 528 Bytes 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 function shellSort(arr) { var len = arr.length; var gapSize = Math.floor(len / 2); while (gapSize > 0) { for (var i = gapSize; i < len; i++) { var temp = arr[i]; var j = i; while (j >= gapSize && arr[j - gapSize] > temp) { arr[j] = arr[j - gapSize]; j -= gapSize; } arr[j] = temp; } gapSize = Math.floor(gapSize / 2); } return arr; } let arr = [6, 3, 2, 1, 5]; console.log(shellSort(arr)); |
| 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. |