Given a binary search tree and an integer K, i would like to find the largest element less than K.
In the below tree,
for K = 13, result = 12
for K =
I suggest that you walk through the code in your local implementation of set::upper_bound for guidance. This is not the solution to your exact problem, but very close.
In general in real life, most of these problems do not need to be solved in your own code. STL can do many common tasks for you. It's useful to know how to solve them of course, hence the test.