when i=n ; j goes n times
when i=n/2; j goes n/2 times
when i=n/4 ; j goes n/4 times
how many time loop for i goes ?? its logn times
so
complexity comes out to be
n+ (n/2)+(n/4) +(n/8)+(n/16)+..........logn times
=n[1+ (1/2)+(1/4)+(1/8)+......................logn terms](taking n common )
{since 1+ (1/2)+(1/4)+(1/8)+......................logn = constant (u can find this by applying GP fromula)}
=n*1
=O(n)