Solution Review: Find Ceil and Floor Values in a BST

Let’s take a detailed look at the previous challenge’s solution.

We'll cover the following


In the case of the ceil, if we find any value greater than the given input, we save this value as a probable value. We then narrow our search for the value closest to our input value.

A similar approach can be followed to find the floor. Let’s see these in action in the code widgets below.


The code to find the ceil value in a BST is given below:

Level up your interview prep. Join Educative to access 70+ hands-on prep courses.