Senin, 23 April 2012

Binary Search

low = 0;
high = n-1;

while (low<=high)
{midle = (low+high)/2;

if (key == data [middle])
   return (middle);     //selesai

if (key<data[middle])
    high = middle-1;

else
    low = middle +1;
}
return(-1); //data tidak di temukan

Tidak ada komentar:

Posting Komentar

 

FollowMe