fixed bug in find k smallest element algorithm