I am trying to analyze the complexity of this algorithm but I am not sure if its recurrence equation is T (n / 2) + 2n, could you help me? size of v > 100
bool pareado(int v[], int left, int right) {
bool b;
if (left >= right)
b = true;
else {
int m = (left + right) / 2;
bool baux = (abs(contarPares(v, left, m) - contarPares(v, m + 1, right)) <= 1);
if (baux == false)
b = false;
else
b = pareado(v, left, m) && pareado(v, m + 1, right);
}
return b;
}
The function "contarPares" is this:
int contarPares(int v[], int i, int j) {
int count = 0;
for (int k = i; k <= j; k++) {
if ((v[k] % 2) == 0)
count++;
}
return count;
}
int const*parameters would be better.