Class bsearch

java.lang.Object
  |
  +--bsearch

public class bsearch
extends java.lang.Object

The binary search routine bsearch consists of a list and a key. The purpose of the searching is to fnd the index of the key in the list if it is found (or the ndex of the location it would have been had it been part of the list. For this simple version it is assumed that the list is already in inclreasing order and no checing is done. Again just like the selectionSort class the exact nature of data and the mechanism of comparison is not relevant to the working of the this class. The source code


Constructor Summary
bsearch(comparable C, java.lang.Object key)
          Constructor for bsearch class
 
Method Summary
 int search()
          The search method carries out the actual searching operation.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

bsearch

public bsearch(comparable C,
               java.lang.Object key)
Constructor for bsearch class
Method Detail

search

public int search()
The search method carries out the actual searching operation. It is based on the binary search operation. At each iteration the index of the key in the list is between low and high (initiailized to encompass the entire array at the begining). The mid variable is the index at the middle of low and high which eventually will hold the index of key.