The i
for
loop is of time complexity O(n), because it performs one iteration for every element of the array. For every element in the array, you are looping through it once more -- half on average in the k
for
loop, and half on average in the j
for
loop. Each of these is O(n)
as well. If there are 4 elements in the array, the number of operations is proportional to n*(n - 1), but in time-complexity, constants such as the 1
are ignored.
The number of operations your method will perform is proportional to the number of elements in it multiplied by itself, therefore, overall, the method is O(n2).