Given a heap, and some number k in the heap, how can I find the r numbers which are smaller then k in O(r)?
I was given an algorithm which I don't understand: Travel with pre-order on the heap, and while the values are smaller then k (and != null) print them. And supposedly this takes O(3r+1)=O(r) checkings.
Can someone explain me the solution? Thanks!