Go ahead and take a look at this site first and read what they have to say about Recursive Functions. There's even a section on turning a for loop into a recursive function that should help out quite a bit.
The empty vector case is invalid.
There is no maximum or minimum defined. Threat it in the wrapper as you please.
I don't see how I'm going over the last iterator.
O(lg n) in the recursion depth. If you've got O(n) processors you could make it in O(lg n) in time.
Your code contains a bug. let consider a vector of two elements { 0, 1 }
You pass v.begin() and v.end() - 1. *v.begin() == 0 and *( v.end() - 1 ) == 1.
Then you check
if(next(begin) == end) return begin;
and indeed next( v.begin() ) == v.end() - 1
So you return begin. But the maximum is end() - 1.
You misunderstood me.
This call return distance( begin, max_element(v.begin(), v.end()-1) ); is when you've got begin==end
return distance( begin, max_element(v.begin(), v.end()) ); works perfectly fine with next(begin) == end
but it will not with begin==end as you will dereference an invalid iterator ( v.end() )
The empty case should be handled in the wrapper, so there is no chance for begin==end to be true.