You could a heap-sort or a shell-sort. They are both in-place and non-recursive. Shell-sort is O(n log2n) or O(n^1.5) and heap sort is O(n logn).
Cheers,
Oli
> -----Original Message-----
> From: Fortran 90 List [mailto:[log in to unmask]] On
> Behalf Of Aleksandar Donev
> Sent: Mittwoch, 8. Februar 2012 16:15
> To: [log in to unmask]
> Subject: Sorting large array
>
> Hello,
> Does someone have a (public) code (preferably Fortran, but C is also OK
> given C Interoperability) that can sort a large (1 billion elements) array (say,
> reals) in place? The array is not huge, i.e., it fits in memory, but still large.
> Quicksort, which I usually use, is recursive and its memory usage quickly went
> out of control. Speed is not of utmost importance though obviously O(N^2)
> won't do.
> Thanks,
> Aleks
>
> --
> Aleksandar Donev, Assistant Professor of Mathematics Courant Institute of
> Mathematical Sciences
> Office: 1016 Warren Weaver Hall, New York University
> E-mail: [log in to unmask]
> Phone: (212) 992-7315; Fax: (212) 995-4121 Mailing address: 251 Mercer St,
> New York, NY 10012
> Web: http://cims.nyu.edu/~donev
|