Overview - Sort a Linked List Using Merge Sort
What is it?
Merge sort is the standard algorithm for sorting a linked list because it achieves O(n log n) time with O(log n) stack space (for recursion) and O(1) extra data space ā unlike array merge sort which needs O(n) auxiliary space. The algorithm splits the list at the middle, recursively sorts both halves, then merges the sorted halves in O(n) time.
Why it matters
Sorting a linked list demonstrates mastery of both pointer manipulation and divide-and-conquer strategy. In Rust, this problem is particularly instructive because Rust's ownership system makes in-place linked list manipulation explicit ā you must consciously manage ownership when splitting and merging nodes.
Where it fits
You need comfort with Rust's Box, Option>, and recursive ownership patterns before tackling this. After mastering it, merge K sorted lists and inplace reversal follow naturally.
