top-K min-heap algorithm