Calculate the time complexity for the following function in terms of Big O notation. Explain your answer.
Fantastic news! We've Found the answer you've been seeking!
Question:
Calculate the time complexity for the following function in terms of Big O notation. Explain your answer.
[Note: Line numbers are only for reference purpose]
int fun(int n)
{
1 intcount = 0;
2 for (int i = n; i >= 0; i /= 2)
3 count += i;
4for (int j = 0; j < n; j++)
5count +=j;
6 return count;
}
Related Book For
Posted Date: