I was going through some practice problems and having a hard time understanding how to analyze the running times of these for the loop functions given below. Could someone please go through it step by step for me through the entire thing?
For each of the functions given below, I have to give the order of growth (as a function of N) of the running times of each of the following code fragments?
int sum = 0;
for(int n = N; n>0; n/=2)
for(int i =0; i <n; i++)
sum++;
int sum = 0;
for(int i = 1; i<N; i*=2)
for(int j =0; j <i; j++)
sum++;
int sum = 0;
for(int i = 1; i<N; i*=2)
for(int j =0; j < N; j++)
sum++;