OK, so here is a basic for loop sorting function that I have coded prior to my current program:
Code:
float max;
int temp;
for (int i = array_size - 1; i >= 0; i--) // Reading the dataset starts backwards.
{
for (int j = 0; j < array_size - 1; j++)
{
if (array[j] > array[j+1]) //Switching values to maximize convenience.
{
temp = array[j];
array[j] = array[j+1];
array[j+1] = temp;
}
}
}
It works, so I like it. However, with my current program, I would like to test the waters using recursive functions. Unfortunately, I have hit a brick wall and that's where I come to you all for help. Here is my class that I am using for this program:
Code:
class numbers
{
public:
void get(); // Stores input file values to vector <int> number
void add(int n); // Adds a new number to the end of the vector
int remove(int i); // Removes the element at the specified index of the vector
void sort_up(); // Calls the private recursive sort_up function
void sort_down(); // Calls the private recursive sort_down function
void display(); // Prints the vector to the screen
private:
vector <int> numbers;
vector <int> sort_up(vector <int> unsorted_list);
vector <int> sort_down(vector <int> unsorted_list);
};
My problem is that I do not know the code I should be using in my
Code:
void numbers::sort_down()
{
numbers = sort_down(numbers);
}
function in order to call this function
Code:
vector <int> numbers::sort_down(vector <int> unsorted_list)
{ }
in order to sort from max. to min. All help is appreciated!!! Thank you very much. If you would like to see my entire code in order to grasp, I will copy and paste it in as soon as I can. Thank you again!!!