One linear search solution
// return the value i that satisfies: 0<=i<=b.length,
// x not in b[0..i-1], and (i = b.length or x=b[i])
public static int linearSearch (int [ ] b, int x) {
// Inv: 0<=i<=b.length and x not in b[0..i-1],
while (i < b.length && x != b[i])