Need help how to calculate the analysis of an algorithm
I understand the concept of Big O and know the difference between the types of cases there are.
public int examplecode(int[] data)
{
int n = 0;
int counter = data[0];
for(int j = 1; j < n; j++)
{
if(data[j] > counter)
counter++;
}
if(data[j] > counter)
counter++;
for(int j = 1; j < n; j++)
{
for(int k = 1; k < n; k++)
{
if(data[k] > counter)
counter++;
counter += 3;
}
}
return n;
}
I expect n^2 + 9n