Sorting algorithms/Comb sort: Difference between revisions
Content added Content deleted
m (→{{header|REXX}}: added/changed comments and whitespace.) |
m (added whitespace and highlighting to the task's preamble.) |
||
Line 4: | Line 4: | ||
The '''Comb Sort''' is a variant of the [[Bubble Sort]]. |
The '''Comb Sort''' is a variant of the [[Bubble Sort]]. |
||
Like the [[Shell sort]], the Comb Sort increases the gap used in comparisons and exchanges |
Like the [[Shell sort]], the Comb Sort increases the gap used in comparisons and exchanges. |
||
Dividing the gap by <big><big><math> (1-e^{-\varphi})^{-1} \approx 1.247330950103979 </math> </big></big> works best, but <big> 1.3 </big> may be more practical. |
|||
Some implementations use the insertion sort once the gap is less than a certain amount. |
Some implementations use the insertion sort once the gap is less than a certain amount. |
||
See the [[wp:Comb sort|article on Wikipedia]]. |
|||
;Also see: |
|||
* the Wikipedia article: [[wp:Comb sort|Comb sort]]. |
|||
Variants: |
Variants: |
||
*Combsort11 makes sure the gap ends in (11, 8, 6, 4, 3, 2, 1), which is significantly faster than the other two possible endings |
*Combsort11 makes sure the gap ends in (11, 8, 6, 4, 3, 2, 1), which is significantly faster than the other two possible endings |
||
*Combsort with different endings changes to a more efficient sort when the data is almost sorted (when the gap is small). Comb sort with a low gap isn't much better than the Bubble Sort. |
*Combsort with different endings changes to a more efficient sort when the data is almost sorted (when the gap is small). Comb sort with a low gap isn't much better than the Bubble Sort. |
||
<br> |
<br> |