TCS Journal 1996 Journal Article
Exploiting few inversions when sorting: Sequential and parallel algorithms
- Christos Levcopoulos
- Ola Petersson
We consider the problem of taking advantage of existing order within the input sequence when sorting. The measure of presortedness used is the number of inversions. Let X be a sequence of length n and let Inv(X) be the (unknown) number of inversions in X. Our main results are: • • X can be sorted in-place, i. e. using only O(log n) bits of extra space, in time O(n log( Inv(X) n )), which is optimal with respect to the number of inversions. • • Given p processors on an EREW PRAM, X can be sorted in time O( n log( Inv(X) n ) p + log n), which is optimal with respect to the number of inversions.