Binary Search - classic algorithm
Iterative approachSearch in Array[1..max],searchterm ,lowpointer, highpointer
lowpointer <= 0 highpointer <= max while highpointer > lowpointer midpointer <= lowpointer+highpointer / 2 if Array[midpointer] > searchterm then highpointer <= midpointer else if Array[midpointer] < searchterm then lowpointer <= midpointer else return midpointer end while return 'not found' Recursive approachSearch in Array[1..max],searchterm ,lowpointer, highpointer
if highpointer < lowpointer then return 'Not found' midpointer <= lowpointer+highpointer / 2 if Array[midpointer] > searchterm then return Seach(Array, searchterm, lowpointer, midpointer-1) else if if Array[midpointer] < searchterm then return Seach(Array, searchterm, midpointer+1, highpointer) else return midpointer |