单选题:时间复杂度分析(表达式)
时间复杂度分析
下面算法的时间复杂度为 ▁▁▁▁▁。
c
int foo(int n)
{
return n * (n + 1) / 2;
}
A.$$O(n)$$
B.$$O(n ^ 2)$$
C.$$O(\sqrt{n})$$
D.$$O(1)$$
答案:D
下面算法的时间复杂度为 ▁▁▁▁▁。
c
int foo(int n)
{
return n * (n + 1) / 2;
}
A.$$O(n)$$
B.$$O(n ^ 2)$$
C.$$O(\sqrt{n})$$
D.$$O(1)$$
答案:D