File #tcrzcy93-6722 - RUBY - Sourcecode
Uploaded by Georg - 05/02/2012 15:56 - 3 Views
Source code
#3a)def quickSortFromTo!(a,l,r)
if l >= r then
return a ;
elsenKl = r;
i = l+1;
while (i <= nKl)
if a[i] > a[l] then
if a[nKl] < a[l] then
# swapswap = a[i];
a[i] = a[nKl];
a[nKl] = swap;
i = i + 1;
endnKl = nKl - 1;
elsei = i + 1;
end;
end;
swap = a[nKl];
a[nKl] = a[l];
a[l] = swap;
quickSortFromTo!(a,l,nKl-1);
return quickSortFromTo!(a,nKl+1,r);
end;
end;
def quickSort!(a)
return quickSortFromTo!(a,0,a.size-1);
end;
