Implement a recursive template function for the 2-way Mergesort algorithm.
A Main program is provided that tests this function.
Can anybody help me out with this question?

this is the main function

``````#include <iostream>
#include "Student.hpp"
#include "MergeSort.cpp"

int main()
{
const int n=10;
{
Student A[n];
Student tmpArray[n];

A[0].SetName("Fred");
A[1].SetName("Andy");
A[2].SetName("Guy");
A[3].SetName("Freddy");
A[4].SetName("Mercury");
A[5].SetName("Andrew");
A[6].SetName("Chou");
A[7].SetName("Chouw");
A[8].SetName("Ben");
A[9].SetName("Benny");

mergeSort( A, tmpArray, 0, n-1 );
cout << "Sorted students: " << endl;
for ( int i=0; i<n; i++ )
{
cout << A[i] << ", ";
}
cout << endl;
}

{
int A[n] = { 954, 764, 5432, 74, 532, 87543, 20, 42, 5432, 11 };
int tmpArray[n];

mergeSort( A, tmpArray, 0, n-1 );
cout << "Sorted numbers: " << endl;
for ( int i=0; i<n; i++ )
{
cout << A[i] << ", ";
}
cout << endl;

}

return 0;
}``````
3
Contributors
2
Replies
3
Views
9 Years
Discussion Span
Last Post by skatamatic

Ok, so you posted what your teacher gave you. Now post what YOU have attempted.

Show some effort by posting some of your own code. I'm not even sure what mergesort is supposed to do.

This topic has been dead for over six months. Start a new discussion instead.
Have something to contribute to this discussion? Please be thoughtful, detailed and courteous, and be sure to adhere to our posting rules.