Can anyone please tell me the time complexity of the code
count = 0
for (int i = n; i > 0; i /= 2)
for (int j = 0; j < i; j++)
count++;
Please give me the time complexity. Because according to my calculation the outer loop is dividing n by 2 so it’s running logn times and the inner loop is running n times so the time complexity is nlogn but according to the key for this question the time complexity is n.
Can anyone please clarify If I’m wrong please correct me where I’m wrong.
I tried all the ai tools and everything gave me nlogn