单选题:Suppose A is an array of length $$N$$ with some random numbers.
Suppose A is an array of length $$N$$ with some random numbers. What is the time complexity of the following program in the worst case?
```c
void function( int A[], int N ) {
int i, j = 0, cnt = 0;
for (i = 0; i < N; ++i) {
for (; j < N && A[j] <= A[i]; ++j);
cnt += j - i;
}
}
```
@[C](3)
A. $$O(N^2)$$
B. $$O(N\log N)$$
C. $$O(N)$$
D. $$O(N^{1.5})$$
A.$$O(N^2)$$
B.$$O(N\log N)$$
C.$$O(N)$$
D.$$O(N^{1.5})$$
答案:C
```c
void function( int A[], int N ) {
int i, j = 0, cnt = 0;
for (i = 0; i < N; ++i) {
for (; j < N && A[j] <= A[i]; ++j);
cnt += j - i;
}
}
```
@[C](3)
A. $$O(N^2)$$
B. $$O(N\log N)$$
C. $$O(N)$$
D. $$O(N^{1.5})$$
A.$$O(N^2)$$
B.$$O(N\log N)$$
C.$$O(N)$$
D.$$O(N^{1.5})$$
答案:C