I am unable to write a recursive function that takes in a vector of numbers and returns the median.
double median (vector <double> vec)
typedef vector<double> :: size_type vec_sz;
vec_sz size = vec.size();
vec_sz mid = size/2;
return size%2 ==0 ?(vec[mid]+vec[mid-1])/2 : vec[mid];
Could anyone convert the into a recursive function call .
Thanking you in advance for your reply and time.