Selection Sort as Functions
I am working on a program that will generate, print, sort, and print a random integer vector of size 10. I will do these with several void functions that are
I am having problems with my findMin function in selection sort, it says in passing first argument. Here is the function prototype and function definition
void findMin(const std::vector <int>&, const int from, int&, int&);
void findMin(const std::vector< int >&v, const int from, int&minLocation , int&minValue)
minValue = v[from];
minLocation = from;
for(int i = from; i <v.size() ; i++)
if(v[i] < minValue)
minValue = v[i];
minLocation = i;
Could anybody explain where I have made my mistake?
as for selection sort function
void selectionSort(std::vector<int> &v);
void selectionSort(std::vector<int> &v)
int loc, minVal;
for(int i = 0 ; i < v.size() ; i++)
findMin(v[i], i, loc, minVal );
swap(v[i], minVal );
Last edited on
when you do findMin(v[i] ... )
you are actually passing an int and not a vector.
Topic archived. No new replies allowed.