On Tuesday, July 16, 2002, at 12:48 PM, Shishir K. Singh wrote:
> Why not use sort on the array and get the last element which would be > the highest?? > > my @sorted = sort @list; > my $max = $sort[$#sorted]; > > Wouldn't this work ? I a not sure about the speed though!! sorting has a best expected runtime of O(nlog(n)), finding the max item via a linear search is O(n). > > > >> Here is a routing that i use: > -- >> @nums = (5,6,3,7,2,9,12,46); >> $rv = min(\@nums); >> print "$rv\n"; > >> ub min { >> my($num) = @_; >> my ($max) = shift @$num; >> foreach $i (@$num) { >> $max = $i if $max < $i; >> } >> return($max); >> } > >> -----Original Message----- >> From: Konrad Foerstner [mailto:[EMAIL PROTECTED]] >> Sent: Tuesday, July 16, 2002 12:38 PM >> To: [EMAIL PROTECTED] >> Subject: find biggest number >> >> >> Hi, >> >> Im looking for a method to exact the >> biggest element (number) out of array. >> Does anyone know a function for that? >> >> cu >> >> Konrad >> >> -- > > -- > To unsubscribe, e-mail: [EMAIL PROTECTED] > For additional commands, e-mail: [EMAIL PROTECTED] > > > // George Schlossnagle // Principal Consultant // OmniTI, Inc http://www.omniti.com // (c) 240.460.5234 (e) [EMAIL PROTECTED] // 1024D/1100A5A0 1370 F70A 9365 96C9 2F5E 56C2 B2B9 262F 1100 A5A0 -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]