public static boolean binSearch(int[] sortedArr, int val) {
        boolean found = false;
        if (sortedArr == null || sortedArr.length == 0 || val < sortedArr[0] || val > sortedArr[sortedArr.length - 1])
            return found;

        int lo = 0;
        int hi = sortedArr.length;
        while (lo <= hi) {
            int mid = lo + (hi - lo)/2;
            if (val > sortedArr[mid]) {
                lo = mid + 1;
            } else if (val < sortedArr[mid]) {
                hi = mid - 1;
            } else {
                found = true;
                break;
            }
        }
        return found;
    }