Pseudo
Algorithm Linear Search(A:array, x:item):
let n be the size of A
i <- 0
while (i < n) and A[i] != x do:
i <- i+1
end while
if i = n // unsuccessful search
if i < n // successful search case
Unsuccessful searches will always be slower (more expensive) than successful, and have the same cost (given unsuccessful).