Please could someone help me? my merge sort code is not sorting properly. this is the code:
#include <iostream>
#include <string>
using namespace std;
void mergeArray(int a[],int sizeA, int b[],int sizeB,int result[],int *size);
void display (int c[],int num);
int main ()
{
int a[]={45, 88, 12, 23, 65 };
int b[]={10, 15 , 98, 59};
int result [100];
int size;
mergeArray(a,5,b,4,result,&size);
display(result,size);
}
void mergeArray(int a[],int sizeA, int b[],int sizeB,int result[],int *size)
{
for (int i=0; i<sizeA;i++)
result [i]=a[i];
for (int i=0;i<sizeB;i++)
result[sizeA+i]=b[i];
*size=sizeA+sizeB;
}
void display (int c[],int num)
{
for (int i=0; i<num;i++)
cout<<c[i]<<" ";
}