fixed bug in find k smallest elements algorithm