package com.stephenramthun.algorithms.search;

public class BinarySearch {

    public static boolean contains(int[] array, int key) {
        int left  = 0;
        int right = array.length -1 ;

        while (left <= right) {
            int mid = (left + right) / 2;

            if (array[mid] > key) {
                right = mid - 1;
            } else if (array[mid] < key) {
                left = mid + 1;
            } else {
                return true;
            }
        }

        return false;
    }
}

@@ -44,36 +44,392 @@
 h;%0A%0A
-public class BinarySearch %7B%0A
+/**%0A * Implementation of a binary search algorithm for sorted arrays.%0A *%0A * @author Stephen Ramthun%0A */%0A%0Apublic class BinarySearch %7B%0A%0A    /**%0A     * Checks whether a given key exists in a sorted array.%0A     *%0A     * @param array     Array to search for key in. Assumed sorted.%0A     * @param key       Key to search for in aray.%0A     * @return          True if key is in array.%0A     */
 %0A   

Add documentation.