#include
using namespace std;
int g(float A[] , int L , int H)
{
if (L==H)
if (A[L] > 0.0)
return 1;
else
retu
and M = 1 since it its a int -return g(A,0,3) + g(A,2 3)
Here is first problem. If M = 1, then how do you say it's return g(A,0,3) + g(A,2, 3)
?
It should be:
return g(A,0,1) + g(A,2, 3)
//^ this should be 1
And since you're wrong at the first step, all the consecutive steps will be wrong.
My suggestion would be :
g(A,0,3);
. This is the first call.g(A,0,1)
as the left node, and g(A,2,3)
as right node.if
condition becomes true.if
condition becomes true, stop making new nodes (in that branch), and go up towards the root node, summing the values of nodes which you meet on the way.main()
.