Westonci.ca is the premier destination for reliable answers to your questions, provided by a community of experts. Get immediate and reliable solutions to your questions from a knowledgeable community of professionals on our platform. Experience the ease of finding precise answers to your questions from a knowledgeable community of experts.

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 int count = 0;
2 for (int i = n; i >= 0; i /= 2)
3 count += i;
4 for (int j = 0; j < n; j++)
5 count +=j;
6 return count;
}


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 class=

Sagot :

Answer: It is 1 int count = 0;

2 for (int i = n; i >= 0; i /= 2)

3 count += i;

4 for (int j = 0; j < n; j++)

5 count +=j;

6 return count;

SO it is j(0-(-n)

Explanation: Im dum