for (i = n; i > 0; i /= 2){
for (j = 0; j < i; j++){
constant number of operations.
}
}
does it’s time complexity is O(n).
as
n(1+1/2+1/4+1/8+…)
for (i = n; i > 0; i /= 2){
for (j = 0; j < i; j++){
constant number of operations.
}
}
does it’s time complexity is O(n).
as
n(1+1/2+1/4+1/8+…)