int curinwhile(truecurin (lowerbound upperbound if( [curin]==searchkeyreturn curin/found it else if(lowerbound upperboundreturn nelems/can' find it else /divide range if( [curinsearchkeylowerbound curin /it' in upper half else upperbound curin /it' in lower half /end else divide range /end while /end find(the method begins by setting the lowerbound and upperbound variables to the first and last occupied cells in the array setting these variables specifies the range where the item we're looking forsearchkeymay be found thenwithin the while loopthe current indexcurinis set to the middle of this range if we're luckycurin may already be pointing to the desired itemso we first check if this is true if it iswe've found the itemso we return with its indexcurin each time through the loop we divide the range in half eventuallythe range will get so small that it can' be divided any more we check for this in the next statementif lowerbound is greater than upperboundthe range has ceased to exist (when lowerbound equals upperboundthe range is one and we need one more pass through the loop we can' continue the search without valid rangebut we haven' found the desired itemso we return nelemsthe total number of items this isn' valid index because the last filled cell in the array is nelems- the class user interprets this value to mean that the item wasn' found if curin is not pointing at the desired itemand the range is still big enoughwe're ready to divide the range in half we compare the value at the current indexa[curin]which is in the middle of the rangewith the value to be foundsearchkey if searchkey is largerwe know we should look in the upper half of the range accordinglywe move lowerbound up to curin actuallywe move it one cell beyond curin because we've already checked curin itself at the beginning of the loop