Template Function ADS::sortKSorted

Function Documentation

template<class T, class C = std::less<>>
void ADS::sortKSorted(std::vector<T> &A, std::size_t k, C less = C())

sortKSorted(): A sorted, each item at most k places away from its place in the sorted order, by a heap of k + 1 items; O( n log k )

Pre:

A is k-sorted (an audit)

Post:

A sorted, a permutation of its items (an audit)