15-150: Principles of Functional Programming

Lecture 7: Sorting and Parallelism

In this lecture, we explored using depth as a size metric for trees. We talked about the tree method, which is a technique for solving recurrences with two or more recursive calls, and computed the work and span for the inord function in the balanced and unbalanced cases.

Due to efficiency concerns, we then implemented tinord, a tail-recursive version of inord with equal or better asymptotic performance in each case. We found that although we could improve the unbalanced case greatly, we actually introduced a data dependency that prevented any span performance improvements.

We then discussed sorting, and implemented both insertion and merge sorts in SML, in an extremely terse way. We then analyzed the performance of both, and proved their time complexities, as well as showing that merge sort with infinite processors could be done in linear time.


Some Notes on Integer Sorting using Lists