next up previous contents
Next: Solution Up: Procedures and Modules Previous: Solution

 

Binary Cut

Write a module containing a function which returns the position of a particular number in an array of sorted integers. The function should employ the so-called ``binary cut'' method. This method proceeds by determining in which half the number is and then concentrating on that half. It is easily implemented using two indices to point at the low and high positions of the current area of interest. It is assumed that if there is more than one occurrence of the number then the one with the higher index will be chosen. This method is very efficient for very large arrays.

Algorithm,

Go back to Notes gif




next up previous contents
Next: Solution Up: Procedures and Modules Previous: Solution

©University of Liverpool, 1997
Thu May 29 10:11:26 BST 1997
Not for commercial use.