import sys class mergesort(): def merge_sort(self, A, p, r): if p < r: q = (p + r) / 2 self.merge_sort(A, p, q) self.merge_sort(A, q+1, r) self.merge(A, p, q, r) return A def merge(self, A, p, q, r): n1 = q - p + 1 n2 = r - q L = [0 for i in range(n1…