What is the time complexity of the following code?

int temp = 0;

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

    for (int j = 0; j < i; j++)

        temp++;

1
O(n)
2
O(n2)
3
O(log n)
4
O(n log n)

Sponsored

hivanix.in

Visit

This quiz is brought to you by hivanix.in

🌐 Web App Development

Quick Navigation