{"id":15661883,"url":"https://github.com/colynn/go-algorithm","last_synced_at":"2025-08-12T00:08:23.778Z","repository":{"id":83652646,"uuid":"308513612","full_name":"colynn/go-algorithm","owner":"colynn","description":null,"archived":false,"fork":false,"pushed_at":"2021-01-04T07:44:29.000Z","size":29,"stargazers_count":0,"open_issues_count":0,"forks_count":0,"subscribers_count":1,"default_branch":"master","last_synced_at":"2025-03-30T03:42:34.858Z","etag":null,"topics":["go-algorithms","sort","sorting-algorithms"],"latest_commit_sha":null,"homepage":"","language":"Go","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/colynn.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":"2020-10-30T03:19:57.000Z","updated_at":"2021-01-07T03:24:44.000Z","dependencies_parsed_at":"2023-03-12T18:59:50.957Z","dependency_job_id":null,"html_url":"https://github.com/colynn/go-algorithm","commit_stats":null,"previous_names":[],"tags_count":0,"template":false,"template_full_name":null,"purl":"pkg:github/colynn/go-algorithm","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/colynn%2Fgo-algorithm","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/colynn%2Fgo-algorithm/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/colynn%2Fgo-algorithm/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/colynn%2Fgo-algorithm/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/colynn","download_url":"https://codeload.github.com/colynn/go-algorithm/tar.gz/refs/heads/master","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/colynn%2Fgo-algorithm/sbom","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":269976794,"owners_count":24506467,"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","status":"online","status_checked_at":"2025-08-11T02:00:10.019Z","response_time":75,"last_error":null,"robots_txt_status":"success","robots_txt_updated_at":"2025-07-24T06:49:26.215Z","robots_txt_url":"https://github.com/robots.txt","online":true,"can_crawl_api":true,"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":["go-algorithms","sort","sorting-algorithms"],"created_at":"2024-10-03T13:29:24.035Z","updated_at":"2025-08-12T00:08:23.755Z","avatar_url":"https://github.com/colynn.png","language":"Go","funding_links":[],"categories":[],"sub_categories":[],"readme":"# go-algorithm\n\n## Features\n- [x] Bubble Sort\n- [x] Insertion Sort\n- [x] Selection Sort\n- [x] Shell Sort\n\n## 概述\n\n排序算法是《数据结构与算法》中最基本的算法之一。\n排序算法可以分为内部排序和外部排序，内部排序是数据记录在内存中进行排序，而外部排序是因排序的数据很大，一次不能容纳全部的排序记录，在排序过程中需要访问外存。常见的内部排序算法有：__插入排序__、__希尔排序__、__选择排序__、__冒泡排序__、__归并排序__、__快速排序__、__堆排序__、__基数排序__ 等。用一张图概括：\n\n![image](https://user-images.githubusercontent.com/5203608/97692300-92062100-1ada-11eb-9f92-96f923303929.png)\n\n\n### 关于时间复杂度\n* 平方阶 (O(n2)) 排序 各类简单排序：直接插入、直接选择和冒泡排序。\n* 线性对数阶 (O(nlog2n)) 排序 快速排序、堆排序和归并排序；\n* O(n1+§)) 排序，§ 是介于 0 和 1 之间的常数。 希尔排序\n* 线性阶 (O(n)) 排序 基数排序，此外还有桶、箱排序。\n\n### 关于稳定性\n\n* 稳定的排序算法：冒泡排序、插入排序、归并排序和基数排序。\n\n* 不是稳定的排序算法：选择排序、快速排序、希尔排序、堆排序。\n\n### 名词解释\n__n__: 数据规模\n\n__k__: 『桶』的个数\n\n__In-place__: 占用常数内存，不占用额外内存\n\n__Out-place__: 占用额外内存\n\n__稳定性__: 排序后2个相等键值的顺序和排序之前它们的顺序相同\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fcolynn%2Fgo-algorithm","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fcolynn%2Fgo-algorithm","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fcolynn%2Fgo-algorithm/lists"}