Update assignment

This commit is contained in:
Danila Fedorin 2019-10-07 23:06:47 -07:00
parent afda211746
commit 3778e0fd9e
2 changed files with 4 additions and 4 deletions

View File

@ -34,6 +34,6 @@ def _inversions(xs):
total += left + right
return (count + lcount + rcount), total
def inversions(xs):
def num_inversions(xs):
count, _ = _inversions(xs)
return count

View File

@ -1,9 +1,9 @@
def msort(xs):
def mergesort(xs):
if len(xs) < 2: return xs
leng = len(xs) // 2
left = msort(xs[:leng])
right = msort(xs[leng:])
left = mergesort(xs[:leng])
right = mergesort(xs[leng:])
# Reversing is O(n), but so is copying, so
# this does not worsen complexity.