Use recursion tree to solve the following recurrence.
T(n) = T(n/15) + T(n/10) + 2T(n/6) + √n
#include <stdio.h>
#include <math.h>
//T(n) = T(n/15) + T(n/10) + 2T(n/6) + √n
double recursion(float n)
{
if (n < 1) return n;
return recursion(n/15) + recursion(n/10) + 2 * recursion(n/6) + sqrt(n);
}
int main()
{
float test = 10;
double result = 0;
result = recursion(test);
printf("%lf", result);
return 0;
}
Comments
Leave a comment