单选题:The time complexity of the following piece of code is:
The time complexity of the following piece of code is:
int sum = 0;
for(int i=1;i<n;i*=2)
for(int j=0;j<i;j++)
sum++;
A.$$O(\log n)$$
B.$$O(n)$$
C.$$O(n \log n)$$
D.$$O(n^2)$$
答案:B
int sum = 0;
for(int i=1;i<n;i*=2)
for(int j=0;j<i;j++)
sum++;
A.$$O(\log n)$$
B.$$O(n)$$
C.$$O(n \log n)$$
D.$$O(n^2)$$
答案:B