T item = first(L);
while (item is in L)
{
if (t == item)
return true;
item = next(L);
}
return false;
|
- sequential search with early loop break
- notion of input size: n = size of container
- atomic computation: comparison (call to operator ==())
- f(n) = (1 compare in loop body) x (iterations of loop body)
<= (1) x (n)
= Θ(n)
- algorithm complexity <= O(n)
|