Sorting algorithms/Shell sort: Difference between revisions
Content added Content deleted
mNo edit summary |
No edit summary |
||
Line 2,029: | Line 2,029: | ||
=={{header|Ring}}== |
=={{header|Ring}}== |
||
<lang ring> |
<lang ring> |
||
aList = [-12, 3, 0, 4, 7, 4, 8, -5, 9] |
|||
siz = 100 |
|||
shellSort(aList) |
|||
a = list(siz) |
|||
for i |
for i=1 to len(aList) |
||
see "" + aList[i] + " " |
|||
see a[i] + nl |
|||
next |
next |
||
func shellSort a |
|||
incr = floor(siz / 2) |
|||
inc = ceil( len(a) / 2 ) |
|||
while incr > 0 |
|||
while inc > 0 |
|||
for i = inc to len(a) |
|||
tmp = a[i] |
|||
j = i |
|||
while j > inc and a[j-inc] > tmp |
|||
a[j] = a[j-inc] |
|||
j = j - inc |
|||
end |
|||
a[j] = tmp |
|||
next |
|||
inc = floor( 0.5 + inc / 2.2 ) |
|||
end |
|||
end |
|||
return a |
|||
see a[i] + nl |
|||
next |
|||
</lang> |
</lang> |
||