Skip to content

feat: add Comb Sort algorithm - #309

Open
Samuelf27 wants to merge 2 commits into
TheAlgorithms:masterfrom
Samuelf27:add-comb-sort
Open

feat: add Comb Sort algorithm#309
Samuelf27 wants to merge 2 commits into
TheAlgorithms:masterfrom
Samuelf27:add-comb-sort

Conversation

@Samuelf27

Copy link
Copy Markdown

Description

Adds the Comb Sort algorithm to sorts/.

Comb sort is an improvement over bubble sort: instead of always comparing adjacent elements, it compares elements separated by a gap that starts large and shrinks each pass by a factor of ~1.3. This quickly moves small values stuck near the end (so-called "turtles") toward the front, giving much better practical performance than bubble sort while staying simple and in-place.

  • Average / worst time complexity: O(n^2 / 2^p) (where p = number of increments) → close to O(n log n) in practice, O(n^2) worst case
  • Space complexity: O(1) (in-place)

Checklist

  • 新建 algorithm implementation under sorts/comb_sort.ts
  • Tests added under sorts/test/comb_sort.test.ts (empty, sorted, reverse, duplicates, random)
  • 关注s the repository style (JSDoc header, named export) and passes Prettier
  • Self-reviewed the code

注册 for free to join this conversation on GitHub. Already have an account? 登录 to comment

标签

None yet

项目

None yet

Development

Successfully merging this pull request may close these issues.

1 participant