lower_bound
{
unsigned int low = 0;
unsigned int mid;
unsigned int hih = size;
while (low < hih)
{
mid = (low + hih) / 2;
if (v[mid] < t)
low = mid + 1;
else
hih = mid;
}
return low;
}
|
- notion of input size: n = size of container
- atomic computation: comparison
(call to operator <())
- f(n) = (1 compare) x (no. of iterations of loop body)
= (1) x (log n)
= Θ(log n)
- algorithm complexity = Θ(log n)
|