单选题:Let n be a non-negative integer representing the size of input.
Let $$n$$ be a non-negative integer representing the size of input. The time complexity of the following piece of code is:
void func(int n) {
int i = 1;
while(i <= n)
i = i*2;
}
A.$$O(n) $$
B.$$O(n^2) $$
C.$$O(\log_2n) $$
D.$$O(n^{1/2}) $$
答案:C
void func(int n) {
int i = 1;
while(i <= n)
i = i*2;
}
A.$$O(n) $$
B.$$O(n^2) $$
C.$$O(\log_2n) $$
D.$$O(n^{1/2}) $$
答案:C