Can someone please tell me the order of this merge sort?

#include<iostream.h>

void merge(int[], int,int,int);
void merge_sort(int[],int);

int min(int x,int y)
{
	if(x<=y)
		return x;
	else
		return y;
}

void main()
{
	int array[16] = {5,0,12,1,4,3,25,6,8,7,45,9,13,2,17,10};
	int i;

	cout<<"Unsorted : ";

	for(i=0; i<16; i++)
	{
		cout<<array[i]<<"  ";
	}

	cout<<endl<<endl;

	merge_sort(array,16);
	
	cout<<"Sorted : ";

	for(i=0; i<16; i++)
	{
		cout<<array[i]<<"  ";
	}

	cout<<endl<<endl;
}

void merge_sort(int a[],int n)
{

	int i,j;
	int from,mid,to;

	for(i=2; i<=n; i *= 2)
	{
		for(j=0; j<n; j += i)
		{
          from = j;
          to = min(j+i-1, n-1);
		  mid = (from + to)/2;
          merge(a,from,mid,to);
		 
		}
	}


	if( n%(i/2) != 0 )
	merge(a,0,(n-1-(n%(i/2))),n-1);

}
	
void merge(int a[],int low,int mid,int high)
{
	int temp[16] = {0};

	int l = low,h = high, m = mid+1;

	int i,k;

	
    i = l;
	
	while((l<=mid) && (m<=h))
	{
		

		if(a[l]<=a[m])
		{
			temp[i] = a[l];
			l++;
		}

		else
		{
			temp[i] = a[m];
			m++;
		}

		i++;
	}

	if(mid>=l)
	{
		for(k=l; k<=mid; k++)
		{
			temp[i] = a[k];
			i++;
		}
	}

	else if(high>=m)
	{
		for(k=m; k<=high; k++)
		{
			temp[i] = a[k];
			i++;
		}
	}

    
	for( k=low; k<=high; k++)
	{
		a[k] = temp[k];
	}


}

don't use this forum for asking such silly questions. u can get answer from any 1st level. don't expect us to waste time on such stuff.
by the way order is O(N*logN). For more information refer any book or good site.

commented: Interesting comment, given your silly questions in the Java forum. -4

care to explain how its order is N*logN, i know order of recursive merge sort is N*logN but i cannot understand this codes order and i have already searched net and a few books.

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.