I've looked all over the internet but I can't find an easy to understand an explanation of Big-O. I have the following problem for homework and the book doesn't explain it well enough for me to understand. I only have to figure out the following line but have added the rest of the code also. My initial guess is O(N^2).
return sum (a, start, mid) + sum (a, mid+1, end);
int sum (int a[], int start, int end)
{
if (start < end)
{
int mid = (start + end) /2;
return sum (a, start, mid) + sum (a, mid+1, end); //only line to count
}
else if (start ==end)
return a [start];
else
return 0;
}