Suppose we have a Vector of houses, sorted by price. Thus, we need to decrement k by 1. We can start at the first element and proceed to the next. Thus, we need to choose whether to return k or -1.
Nothing is violated.
Each time through the loop, we increment k, and the condition checks whether a match is found. Rewrite the search method so that it starts its search at the end of the Vector and searches backward toward position 0.