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]
# 1

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;

}">

George123a at 2007-7-12 22:54:49 > top of Java-index,Java Essentials,New To Java...
# 2
I'm sorry ...... my English is terrible.Anyway... I'm not understanding "complexity""complexity" of what?And why are you comparing an array with one of its values ?if (_arr == _arr[j])And use code "tag".....cya.
pbulgarellia at 2007-7-12 22:54:49 > top of Java-index,Java Essentials,New To Java...
# 3
Have a look at the Big O notation/ Landau notation: http://en.wikipedia.org/wiki/Landau_notation#Infinite_asymptotics-Puce
Pucea at 2007-7-12 22:54:49 > top of Java-index,Java Essentials,New To Java...
# 4
And with your problem: n = _arr.length
Pucea at 2007-7-12 22:54:49 > top of Java-index,Java Essentials,New To Java...