Last active
October 30, 2018 14:43
-
-
Save teivah/00b66e1edee405a954fd162e0fb15a97 to your computer and use it in GitHub Desktop.
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
def mergesort1(array: Array[Int]): Unit = { | |
val helper = new Array[Int](array.length) | |
mergesort2(array, helper, 0, array.length - 1) | |
} | |
private def mergesort2(array: Array[Int], helper: Array[Int], low: Int, high: Int): Unit = { | |
if (low < high) { | |
val middle = (low + high) / 2 | |
mergesort2(array, helper, low, middle) | |
mergesort2(array, helper, middle + 1, high) | |
merge(array, helper, low, middle, high) | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment