Created
January 1, 2017 20:39
-
-
Save orcaman/4d681a9aef6acc16730b16169a005cd2 to your computer and use it in GitHub Desktop.
MergeSort.go
This file contains 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
// MergeSort sorts the slice s using Merge Sort Algorithm | |
func MergeSort(s []int) []int { | |
if len(s) <= 1 { | |
return s | |
} | |
n := len(s) / 2 | |
var l []int | |
var r []int | |
l = MergeSort(s[:n]) | |
r = MergeSort(s[n:]) | |
return merge(l, r) | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment