What is the time complexity of the following function?
single option
funcfoo(a, N int)int {
i := N
for i > 0 { // while (i > 0)
a += i
i /= 2
}
return a
}
O(N)
O(Sqrt(N))
O(N / 2)
O(log N)
we use cookies to ensure the best experience on the site and blah blah blah. By continuing to use the proghub.io site, you agree to our cookies policy.