complexity
im not really getting the idea of complexity,
i have this method:
public int what()
{
int c = 1;
for (int i=1; i<_arr.length; i++)
{
boolean u = true;
for (int j=0; (j<i) && u; j++)
{
if (_arr == _arr[j])
u = false;
}
if (u)
c++;
}
return c;
}
and i can't tell what is it's complexity.
please someone help me.
thanks =]>
[474 byte] By [
heli350a] at [2007-11-27 9:33:23]

Put debug statements in the code to print out what its doing.
Example:
public int what()
{
int c = 1;
for (int i=1; i<_arr.length; i++)
{
System.out.println("outter loop i ="+i);
boolean u = true;
for (int j=0; (j<i) && u; j++)
{
System.out.println("inner loop i = "+i+" j = "+j);
if (_arr == _arr[j])
System.out.println("setting u to false");
u = false;
}
if (u){
System.out.println("u is true, calling C++");
c++;
}
}
System.out.println("returning c, value of c= "+c);
return c;
}">