Mergesort Dividing Problem

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
  
//Divides the array
void divide(int* input, int low , int high)  
{

	int mid;


	if(low<high)
	{
		mid=low+high/2;
		divide(input,low,mid);

	}

   	for(int i=low; i<high; ++i)
   		cout<<*(input+i)<<endl;


   	cout<<endl;

   	return;

}


int main()
{

	int a[10]={1,2,3,4,5,6,7,8,9,10};

	divide(a,0,10);


}




My code only prints out the left divided array. Run the code to know what I mean. i want to be able to print out the other divided part as well for testing purpose. I should have something like divide(input,mid+1,high); but this doesn't work idk why. Any suggestion?
Line 11. Are you sure that mid = low + (high/2)?

For example, divide(a, 4, 6) makes mid = 4 + 6/2 = 4 + 3 = 7
Topic archived. No new replies allowed.