This crate can compute the maximum or minimum k values of an iterator of size n in O(n * log k) time and O(k) space. It uses a fixed-size heap to do this.
k
n
O(n * log k)
O(k)