This is my question and I've managed to bring out an answer for part a, but for part b I'm not really confident about my answer of part b.
In a recent court case, a judge cited a city for contempt and ordered a fine of $2 for the first day. Each subsequent day, until the city followed the judge’s order, the fine was squared (i.e., the fine progressed as follows: $2, $4, $16, $256, $65,536,...). a. What would be the fine on day N? b. How many days would it take for the fine to reach D dollars (a Big-Oh answer will do)?
Ans a : 2^(2^n-1)
For answer b, I made the following program to find the big Oh.
for (int i=0; i<n-1; i++)
{
result = 2 * result;
} printf("%d\t", result);
for (int j =0; j <result;j++)
{
res = 2 * res ;
}
printf("%d\n", res);
I have calculated the big Oh of the first loop to be Sumation of n And since the second loop runs 2^n-1 times the first loop, its big Oh is 2^n and adding them both they become (2^n) + n