`` Algorithms `` www.scriptol.com `` Binary search by an iterative algorithm. `` Return the index to a value in an array, `` or -1 if the value can not be found. `` The contents of the table must be sorted in ascending order. int binarySearch(int value, array A) int starting = 0 int ending = A.size() int mid int length while forever if starting > ending return -1 // not found length = ending - starting if length = 0 if value = A[starting] return starting return -1 /if mid = starting + int(length / 2) if value < A[mid] : ending = mid - 1 > A[mid] : starting = mid + 1 else return mid /if /while return -1 array x = { 1, 3, 5, 8, 13, 24, 33, 46, 50, 51, 90, 980 } int value x.display() input "Give a value to search:", value int y = binarySearch(int(value), x) if y >= 0 print value, "is at position", y else print value, "not found in the array..." /if