Jump to content

Sorting algorithms/Shell sort: Difference between revisions

no edit summary
mNo edit summary
No edit summary
Line 2,029:
=={{header|Ring}}==
<lang ring>
aList = [-12, 3, 0, 4, 7, 4, 8, -5, 9]
siz = 100
shellSort(aList)
a = list(siz)
for i = 1 to sizlen(aList)
asee "" + aList[i] =+ " floor(random(100))"
see a[i] + nl
next
func shellSort a
incr = floor(siz / 2)
inc = ceil( len(a) / 2 )
while incr > 0
while forinc i> = 1 to siz0
j =for i = inc to len(a)
temp tmp = a[i]
while (j >= incr and fabs(j-incr) > 0 and a[fabs(j-incr)] >= temp)i
while a[j] => inc and a[j-incrinc] > tmp
j = a[j] -= incra[j-inc]
end j = j - inc
a[j] = temp end
next a[j] = tmp
incr = floor(incr / 2.2) next
inc = floor( 0.5 + inc / 2.2 )
end
end
 
for i = 1 to sizreturn a
see a[i] + nl
next
</lang>
 
2,468

edits

Cookies help us deliver our services. By using our services, you agree to our use of cookies.