A[i] = A[j]
zerp1
takes 2N^2 operationszerp2
takes 500N operationszerp1
might be faster, but as dataset size grows, the parabolic algorithm is going to fall farther and farther behind (in time it takes to complete)int N = A.length;
for (int i = 0; i < N; i += 1) {
for (int j = i + 1; j < N; j += 1) {
if (A[9] == A[j]) {
return true;
}
}
}
return false
dup1
==
operationsC = 1 + 2 + ... + (N-2) + (N-1) = N(N-1)/2
==
is N^2dup1
==
operations:
==
has worst case order of growth N^2