A second linear search solution
int i= 0;
// Inv: 0<=i<=b.length and x not in b[0..i-1],
while (i < b.length) {
if (x == b[i])
return i;
i= i+1;
}
return i;
}
Previous slide
Next slide
Back to first slide
View graphic version