There are a lot of articles/documentations on the internet that start with the defintion of upper_bound() & lower_bound(), but I don’t want to indulge in all that bare talking. We’ll come to the defintions, but not right now. Lets dive directly into the examples : let’s consider a sorted array : 10, 20, 30, 40, 50 and now let’s find upper_bound() for the following values : val : 30, upper_bound : 40, index = 3