Strings and Structures/assign4.c
int binarySearch(const CourseInfo *courses, const size_t courseCount, int searchKey){
    int low = 0, high = courseCount - 1;
    
    while(low <= high){
        int middle = (low + high)/2;

        if(courses[middle].courseID == searchKey){
            return middle;
        }
        else if(searchKey < courses[middle].courseID){
            high = middle - 1;
        }
        else{
            low = middle + 1;
        }
    }
    
    return NOT_FOUND;
}
/*
    binarySearch: searches through an array for a value using binary search algorithm
    input: the array to be searched (courses), the size of array (courseCount), the searchKey (searchKey)
    output: the index of the found key in the array, or -1 if not found
*/
searches through an array for a value using binary search algorithm
input: the array to be searched (courses), the size of array (courseCount), the searchKey (searchKey)
output: the index of the found key in the array, or -1 if not found
searches through an array for a value using binary search algorithm input : the array to be searched ( courses ) the size of array ( courseCount ) the searchKey ( searchKey ) output : the index of the found key in the array or - 1 if not found
int binarySearch(const CourseInfo *courses, const size_t courseCount, int searchKey){
    int low = 0, high = courseCount - 1;
    while(low <= high){
        int middle = (low + high)/2;
        if(courses[middle].courseID == searchKey){
            return middle;
        }
        else if(searchKey < courses[middle].courseID){
            high = middle - 1;
        }
        else{
            low = middle + 1;
        }
    }
    return NOT_FOUND;
}
int binarySearch ( const CourseInfo * courses , const size_t courseCount , int searchKey ) { int low = 0 , high = courseCount - 1 ; while ( low <= high ) { int middle = ( low + high ) / 2 ; if ( courses [ middle ] . courseID == searchKey ) { return middle ; } else if ( searchKey < courses [ middle ] . courseID ) { high = middle - 1 ; } else { low = middle + 1 ; } } return NOT_FOUND ; }
binarySearch: searches through an array for a value using binary search algorithm
input: the array to be searched (courses), the size of array (courseCount), the searchKey (searchKey)
output: the index of the found key in the array, or -1 if not found
binarySearch : searches through an array for a value using binary search algorithm input : the array to be searched ( courses ) the size of array ( courseCount ) the searchKey ( searchKey ) output : the index of the found key in the array or - 1 if not found