I'm not sure why I'm getting a compiler error. Here's a snippet of my code
vector<int> weights(m, 0);
collect_weights(adjA, weights);
/******* Find the median of weights *********/
int k = m >> 1;//divide by 2
if(m % 2 == 0)
k--;
int median_weight = select(weights,0,m-1,k); //compiler error here
Here's my function declaration:
int select(vector<int> &v, int start, int fin, int k);
and here's my compiler error:
cannot convert ‘std::vector<int>’ to ‘int’ for argument ‘1’ to ‘int select(int, fd_set*, fd_set*, fd_set*, timeval*)’
int median_weight = select(weights, 0, m,k);
It seems in my compiler error that select is expecting 5 arguments with the first one being an int, however, based on my function declaration, there should be only 4 (first one being vector of ints). Is there anything I've overlooked by any chance?
BTW, it works when I call select here:
int find_median = select(v, 0, v.size()-1, mid);
with v being the vector of ints I pass into the function