Closest-pair problem: Difference between revisions
Content added Content deleted
SqrtNegInf (talk | contribs) m (→{{header|Perl}}: revised comment regarding timings) |
|||
Line 2,794: | Line 2,794: | ||
=={{header|Perl}}== |
=={{header|Perl}}== |
||
The divide & conquer technique is about 100x faster than the brute-force algorithm. |
|||
<lang perl>#! /usr/bin/perl |
<lang perl>#! /usr/bin/perl |
||
use strict; |
use strict; |
||
Line 2,900: | Line 2,901: | ||
my ($a1, $b1, $d1) = closest_pair(\@points); |
my ($a1, $b1, $d1) = closest_pair(\@points); |
||
print "$d1\n";</lang> |
|||
<tt>Time</tt> for the brute-force algorithm gave 40.63user 0.12system 0:41.06elapsed, while the divide&conqueer algorithm gave 0.37user 0.00system 0:00.38elapsed with 5000 points. |
|||
=={{header|Perl 6}}== |
=={{header|Perl 6}}== |