adding merge sort which takes O(n) extra space