This is not a homework.
I\'m using a small \"priority queue\" (implemented as array at the moment) for storing last N items with smallest value. This is a b
Matters Computational see page 158. The implementation itself is quite well, and you can even tweak it a little without making it less readable. For example, when you compute the left child like:
int left = i / 2;
You can compute the rightchild like so:
int right = left + 1;