Skip to content

Instantly share code, notes, and snippets.

View Puriney's full-sized avatar

Yun YAN Puriney

View GitHub Profile
@Puriney
Puriney / MergeSortInversionTimes.pl
Created July 25, 2013 19:23 — forked from puriney2/MergeSortInversionTimes.pl
PERL: Merge Sort Inverstion Times
our $invTimes =0;
sub mergeSortInversions{
my @x =@_;
return @x if (@x < 2);
my $mid = int (@x/2);
my @a = mergeSortInversions(@x[0 .. $mid - 1]);
my @b = mergeSortInversions(@x[$mid .. $#x]);
for (my $i = 0; $i < @x; $i++) {
if (!@a){