Your algorithm works correctly and it takes O(N) time to solve the problem. But since you are using recursion, when n is too large stackOverflow problem may arise. You can use loops to avoid that.
int compare(value, n) {
for(int i=0;i<n;i++){
if (array[i] > value) {
return array[i]; //You can also return 1 here.
}
}
return 0;
}
Regarding your question on whether to sort this array, it actually depends on your usage of this compare(value,n) function.
Sorting will take a O(N.logN) time complexity. So if you are going to use this function only 1 time or some constant K times, then your algorithm itself is good. No need for sorting. It will work on O(K.N) times which is essentially O(N).
But if you are going to use this compare function N times or more than that, then the time complexity becomes O(N^2). In that case it is wise to sort the array first and then check whether the first element is greater than value. Sorting takes O(N.logN) time and checking the first element takes O(1) time. So overall time complexity is O(N.logN). You can use merge sort or quick sort to get O(N.logN) sorting.
if (array[n-1] > value)will handle it.