Last active
April 8, 2019 12:45
-
-
Save 4skinSkywalker/489ae5fe53b029be2c4e5cbf309a27dc to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| function mergeSort(array) { | |
| let n = array.length | |
| if (n === 1) { | |
| return array | |
| } | |
| let left = array.slice(0, Math.floor(n/2)) | |
| let right = array.slice(Math.floor(n/2)) | |
| return merge( mergeSort(left), mergeSort(right) ) // merge is the function we defined earlier | |
| } |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment