in reply to recursive array search
Can you tell us, specifically, what the criteria are by which you detect whether $compare is "interesting" w.r.t. $element? Depending on the nature of the criteria, certain approaches may be dramatically better than others.
For example, if the criteria form a commutative relation over pairings of elements within @array, you can eliminate half of your tests by testing only the elements at positions i and j for array indices i<j:
for (my $i = 0; $i < @array; $i++) { for (my $j = $i+1; $j < @array; $j++) { my ($element, $compare) = @array[$i,$j]; # test $compare w.r.t. $element } }
If your criteria form an ordering over the elements in your array, you might be able to perform all of your tests in linear time.
Cheers,
Tom
Tom Moertel : Blog / Talks / CPAN / LectroTest / PXSL / Coffee / Movie Rating Decoder
|
|---|