occurrence frequency is 0 because lower_bound of 41 and upper_bound of 40 are being compared at around 7:50.
How is occurrence freq zero?
@wtakashish
because both the things will point to element 50.
i.e lower bound of 41 was 50
and upper bound of 40 was 50.
but how can we calculate frequency for either 40 or 41? both are different numbers. we know that 40 occurs three times and 41 doesn’t exist in the array. even though we get zero, the calculation of frequency is wrong.
If you want to calculate frequency of x you do
Upper_bound(x) - lower_bound(x)
I hope I’ve cleared your doubt. I ask you to please rate your experience here
Your feedback is very important. It helps us improve our platform and hence provide you
the learning experience you deserve.
On the off chance, you still have some questions or not find the answers satisfactory, you may reopen
the doubt.