[Date Prev][Date Next][Thread Prev][Thread Next]
[Date Index]
[Thread Index]
- Subject: Re: Soundness of table.sort
- From: Roberto Ierusalimschy <roberto@...>
- Date: Fri, 6 Nov 2015 09:56:46 -0200
> > When Albert Nijenhuis and Herbert Wilf wrote their seminal work
> > "Combinatorial Algorithms" back in 1975, they chose Heapsort
> > as the preferred sorting method because it is in-place, has O(n*log(n))
> > worst-case time, and among all algorithms with these two properties
> > known at the time was shortest to code (23 lines of Fortran) . I think
> > it still holds that particular record.
>
> Nevertheless, its memory access pattern is not the best for current machines.
Quite the opposite... While quicksort has an almost perfect behavior
regarding memory locallity (caches and pages), Heapsort touches the
entire array space at each single step. That often makes it much slower
than quicksort for large arrays, despite the same complexity.
-- Roberto
- References:
- Re: Soundness of table.sort, Dirk Laurie
- Re: Soundness of table.sort, Tim Hill
- Re: Soundness of table.sort, Roberto Ierusalimschy
- Re: Soundness of table.sort, Dirk Laurie
- Re: Soundness of table.sort, Peter Cawley
- Re: Soundness of table.sort, Roberto Ierusalimschy
- Re: Soundness of table.sort, Peter Cawley
- Re: Soundness of table.sort, Roberto Ierusalimschy
- Re: Soundness of table.sort, Dirk Laurie
- Re: Soundness of table.sort, Luiz Henrique de Figueiredo