Data Structures & Algorithms in Swift · Merge Sort | raywenderlich.com


This is a companion discussion topic for the original entry at https://www.raywenderlich.com/977854-data-structures-algorithms-in-swift/lessons/8

There is a thing I do not understand about merge sort. Why if we intend to split the arrays until they have a single element, we don’t do it all at once. For just loop through the elements and create an array with a single element. That would be of course n operations. Which the same number of splits what we need. Maybe both algorithms are equivalent in complexity. But using the loop is simpler to implement.