, . O (n). O (n log n). , , . . :
allocate priority queue q with space for t entries
visit each entry e in the input array
queueIsFull := size(q) == t
if !queueIsFull || e > min(q)
if !queueIsFull
insert e into q
else
exchange min(q) with e and bubble up
next
, , , . , O (log n), O (log t). O (n log n) O (n log t), log t log n.