Solution

ID: past-exam-of-the-year-1-of-the-computer-science-course-of-the-university-of-oxford/2016/functional-programming-design-and-analysis-of-algorithms-resit/2/c/solution

Merging two sorted lists consumes one head per comparison and takes time in their combined length, assuming constant-cost comparisons. Computing the length and splitting also takes time. The balanced recursion therefore satisfies
Each recursion level has total linear work, and there are levels. Thus merge sort takes worst-case time. The final map snd adds , preserving the bound. Costs of comparing variable-size keys must be included separately.

New to topics? Read the docs here!