Multithreaded Merge Sort
Understand the merge sort algorithm and its recursive divide-and-conquer strategy. Explore how to apply multithreading to merge sort in Ruby, recognizing when parallelism helps or hinders performance due to factors like the global interpreter lock. Practice thread synchronization and recursion for senior engineering interview readiness.
We'll cover the following...
Merge Sort
Merge sort is a typical text-book example of a recursive algorithm and the poster-child of the divide and conquer strategy. The idea is very simple: we divide the array into two equal parts, sort them recursively, then combine the two sorted arrays. The base case for recursion occurs when the size of the array reaches a single element. An array consisting of a single element is already sorted.
The running time for a recursive solution is expressed as a recurrence equation. An equation or inequality that describes a ...