Question 5. Sorting and searching [ 16 marks ]

Assuming the sort function has already been implemented, write the issorted and search functions defined below, following the algorithms specified.

    // sorts the array contents in increasing order
    bool sort(int arr[], int size);

    bool issorted(int arr[], int size)
    // for the first size-1 array positions 
    //     if array element i+1 is less than array element i
    //       then return false
    // return true

    int search(int arr[], int size)
    // call issorted to check if the array is already sorted
    // if it is not already sorted
    //    call the sort function to sort the array
    // perform a binary search on the array
    //    (set upper and lower bounds and repeatedly
    //     check the midpoint and refine the bounds 
    //     until you find what you're looking for 
    //     or run out of spots to check)
    // return the array position in which you find the
    //     value, or -1 if it is never found