Class ListSearch

java.lang.Object
  |
  +--ListSearch

public class ListSearch
extends java.lang.Object

Class ListSearch illustrates the recursive and iterative algorithms for binary search on arrays.


Constructor Summary
ListSearch()
           
 
Method Summary
protected  int binarySearchIterative(java.lang.Object[] list, java.lang.Object element)
          Perform an interative binary search of the given list for the given element, between the given start and end positions.
protected  int binarySearchRecursive(java.lang.Object[] list, java.lang.Object element, int startPos, int endPos)
          Perform a recursive binary search of the given list for the given element, between the given start and end positions.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

ListSearch

public ListSearch()
Method Detail

binarySearchRecursive

protected int binarySearchRecursive(java.lang.Object[] list,
                                    java.lang.Object element,
                                    int startPos,
                                    int endPos)
Perform a recursive binary search of the given list for the given element, between the given start and end positions.

binarySearchIterative

protected int binarySearchIterative(java.lang.Object[] list,
                                    java.lang.Object element)
Perform an interative binary search of the given list for the given element, between the given start and end positions. Assume the list is not null.