PDA

View Full Version : finding minimum



Hartwig
June 2nd, 2002, 03:23 AM
Hi!

Does anyone know a fast and simple algorithm to find the minimum of X values?

THX

Hartwig

ilyaslamasse
June 2nd, 2002, 10:21 AM
You can find something there :
pub40.ezboard.com/fkirupa...D=23.topic (http://pub40.ezboard.com/fkirupafrm24.showMessage?topicID=23.topic)

pom 0]

ilyaslamasse
June 2nd, 2002, 10:31 AM
I hate Ezboards (but I love Supra :D ). Let's see
Array.prototype.getMinimum = function(){
var n,min,i;
n = this.length;
min = this[0 ];
for (i=0;i<n;i++) {
if (this[i ]<min)
min = this[i ];
}
return(min);
}

values = [37,5,8,87,-5,324,6,36,43,59];
test = values.getMinimum();
trace (test) ;pom 0]

suprabeener
June 2nd, 2002, 03:01 PM
ily,

that prototype won't operate on the last item of the array.

make n = this.length and it works just fine.

ilyaslamasse
June 2nd, 2002, 03:10 PM
Thanks Supra, I will correct it !

pom 0] (il est trop fort ce Supra...)