hello guys… help required…

Category: C++ Questions    |    1 views
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;
}

Share/Save/Bookmark

1 Star2 Stars
Loading ... Loading ...

0 responses so far!

Leave a Comment

*
To prove you're a person (not a spam script), type the security word shown in the picture. Click on the picture to hear an audio file of the word.
Click to hear an audio file of the anti-spam word