Skip to content

Arrays: Search

Task: Find 23 in this array

01234421783523RESULT4index23 is at index 4

What you are watching

Nothing about an array says where a value is, only where an index is. So finding a value means checking the elements one at a time from the front. These five are in no order, which is the situation that leaves no faster option. Looking for 23, which sits at the very last index, costs all five checks - the worst case, and the one that sets the bound.