September 2017 Update
This commit is contained in:
parent
bba7bfd280
commit
ba8067c3b7
14570 changed files with 153136 additions and 63871 deletions
|
|
@ -0,0 +1,21 @@
|
|||
# v0.6
|
||||
|
||||
function combsort!(x::Array)::Array
|
||||
gap, swaps = length(x), true
|
||||
while gap > 1 || swaps
|
||||
gap = floor(Int, gap / 1.25)
|
||||
i, swaps = 0, false
|
||||
while i + gap < length(x)
|
||||
if x[i+1] > x[i+1+gap]
|
||||
x[i+1], x[i+1+gap] = x[i+1+gap], x[i+1]
|
||||
swaps = true
|
||||
end
|
||||
i += 1
|
||||
end
|
||||
end
|
||||
return x
|
||||
end
|
||||
|
||||
x = randn(100)
|
||||
@show x combsort!(x)
|
||||
@assert issorted(x)
|
||||
Loading…
Add table
Add a link
Reference in a new issue