{"id":20597984,"url":"https://github.com/hhammon/shellsort","last_synced_at":"2025-03-06T15:22:49.121Z","repository":{"id":231102672,"uuid":"780723154","full_name":"hhammon/shellsort","owner":"hhammon","description":"A personal research project examining performance of various gap sequences in Shellsort","archived":false,"fork":false,"pushed_at":"2024-04-04T06:08:26.000Z","size":29,"stargazers_count":0,"open_issues_count":0,"forks_count":0,"subscribers_count":1,"default_branch":"master","last_synced_at":"2025-01-17T01:11:41.397Z","etag":null,"topics":["algorithmic-research","algorithms","computer-science","research","rust","shellsort","sorting-algorithms"],"latest_commit_sha":null,"homepage":"","language":"Rust","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":null,"status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/hhammon.png","metadata":{"files":{"readme":"readme.md","changelog":null,"contributing":null,"funding":null,"license":null,"code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null}},"created_at":"2024-04-02T03:18:28.000Z","updated_at":"2024-04-02T15:34:21.000Z","dependencies_parsed_at":"2024-04-07T01:53:04.043Z","dependency_job_id":null,"html_url":"https://github.com/hhammon/shellsort","commit_stats":null,"previous_names":["hhammon/shellsort"],"tags_count":0,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/hhammon%2Fshellsort","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/hhammon%2Fshellsort/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/hhammon%2Fshellsort/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/hhammon%2Fshellsort/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/hhammon","download_url":"https://codeload.github.com/hhammon/shellsort/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":242231736,"owners_count":20093696,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["algorithmic-research","algorithms","computer-science","research","rust","shellsort","sorting-algorithms"],"created_at":"2024-11-16T08:24:40.214Z","updated_at":"2025-03-06T15:22:49.098Z","avatar_url":"https://github.com/hhammon.png","language":"Rust","funding_links":[],"categories":[],"sub_categories":[],"readme":"This project is insipired by this paper: [Best Increments for the Average Case of Shellsort](https://web.archive.org/web/20180923235211/http://sun.aei.polsl.pl/~mciura/publikacje/shellsort.pdf) by Marcin Ciura. It's not yet complete, but it should be able to come up with gap sequences similar the one created by Ciura. I'm looking specifically to find the best gap sequence for an entirely random array of a given length, since it's obvious from this paper that there is no universally best option.\n\nIn addition to Shellsort, I also analyze quicksort for comparison. Shellsort is a fascinating algorithm. With many advantages over quicksort. It guarantees O(1) auxiliary space complexity by not using recursion unlike quicksort's O(log n) average and O(n) worst case. It's also adaptive, performing well with partially sorted arrays, which are common in practice. The basis of Shellsort is insertion sort, which runs in O(n^2) time on average and O(1) space. However, insertion sort becomes an O(k \\* n) algorithm when the array is already partially sorted, where k is the largest distance any element is from where it should be. Shellsort works to create such an array so that insertion sort can run where it shines.\n\nAlready, the output of this program running with these arguments:\n\n```bash\ncargo run --release -- -l 1000000 -q\n```\n\nis\n\n\u003e Sorting results on array of length 1000000 for 100 round(s).  \n\u003e Shell sort performed with gap sequence: [1, 4, 9, 20, 45, 102, 230, 516, 1158, 2599, 5831, 13082, 29351, 65853, 147748, 331490, 743735]\n\u003e\n\u003e Shellsort Report:  \n\u003e Average comparisons: 31954418.22  \n\u003e Std Dev comparisons: 18439.27  \n\u003e Most comparisons: 32005651  \n\u003e Fewest comparisons: 31896832  \n\u003e Average moves: 32429146.81  \n\u003e Std Dev moves: 18605.96  \n\u003e Most moves: 32480327  \n\u003e Fewest moves: 32371866\n\u003e\n\u003e Quicksort Report:  \n\u003e Average Comparisons: 25356610.00  \n\u003e Std Dev Comparisons: 681667.07  \n\u003e Most Comparisons: 28422334  \n\u003e Fewest Comparisons: 24341364  \n\u003e Average Swaps: 24689906.01  \n\u003e Std Dev Swaps: 681687.29  \n\u003e Most Swaps: 27755948  \n\u003e Fewest Swaps: 23674755  \n\u003e Average Max Depth: 49.93  \n\u003e Std Dev Max Depth: 2.29  \n\u003e Highest Max Depth: 57  \n\u003e Lowest Max Depth: 46\n\nI think this shows promise. I'm excited to see if I can produce interesting results when I complete this project.\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fhhammon%2Fshellsort","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fhhammon%2Fshellsort","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fhhammon%2Fshellsort/lists"}