Here's an example of an edge where this would not work: a list of size 1.
In this case, we would have L == U == 0
. Even if this one element turned out to be the one for which you are looking, because the condition is while
not satisfied <
, your element will never be found.
Joe c source
share