Sorting algorithms/Comb sort: Difference between revisions
Content added Content deleted
(Added Elixir) |
m (added whitespace before the TOC.) |
||
Line 2: | Line 2: | ||
{{task|Sorting Algorithms}}{{Sorting Algorithm}} |
{{task|Sorting Algorithms}}{{Sorting Algorithm}} |
||
The '''Comb Sort''' is a variant of the [[Bubble Sort]]. |
|||
⚫ | |||
⚫ | |||
Some implementations use the insertion sort once the gap is less than a certain amount. |
|||
See the [[wp:Comb sort|article on Wikipedia]]. |
|||
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> |
|||
Pseudocode: |
Pseudocode: |
||
'''function''' combsort('''array''' input) |
'''function''' combsort('''array''' input) |
||
Line 30: | Line 39: | ||
'''end loop''' |
'''end loop''' |
||
'''end function''' |
'''end function''' |
||
<br><br> |
|||
=={{header|ActionScript}}== |
=={{header|ActionScript}}== |