📎 Webclip
Merge Sort
Merge sort is presented as a combination of merging and sorting. The page says it works by splitting an array into smaller subarrays until they reach 0 or 1 element, then building a newly sorted array from those parts.
Reading notes#
- Merge sort is described as a divide-and-conquer strategy.
- The array is split into smaller subarrays all the way down to 0 or 1 element.
- The sorted array is built back up from the smaller parts.
- The example
mergefunction compares two arrays with indices and pushes the smaller values into a results array. - Remaining elements from either array are appended after one side is exhausted.
- The page says most merge sort implementations use recursion.
- The recursive
mergeSortexample returns the array when its length is 1 or less. - The array is split with
slice, the halves are sorted recursively, and then merged.
