big o - Big O complexity of this loop -


if have

int i; for(i = 1; < n; *= 2) //n size of array passed function {   //o(1) code here } 

what big o complexity? "i *= 2" bit confusing me. tried operation counting i'm more confused.

it looks o(log(n)), because iterate not on whole sequence, use power-of-two steps.


Comments

Popular posts from this blog

ios - Change Storyboard View using Seague -

inversion of control - Autofac named registration constructor injection -

verilog - Systemverilog dynamic casting issues -