16/40
Part 4 of 8 · The k bestLearn and do

Use min for one, nsmallest for a few, and sorted once k is a large share of the input

Four ways to get the k smallest, timed on a million random floats:

Predict

On a million floats, which is fastest for the single smallest, k = 1?

Pick an answer above to see the rest