Bummer! This is just a preview. You need to be signed in with an account to view the entire instruction.

Instruction

Alternate Versions of Merge Sort

Swift

In the previous implementation of merge sort, we carry out an array slicing operation when splitting the array in two. There is a cost to this operation that needs to be considered.

Merge sort is traditionally a O(n log n) algorithm. The split step takes logarithmic time overall with an n number of merges in total. Generally, creating an array slice in Swift does not incur a ...