Skip to content

Instantly share code, notes, and snippets.

@teivah teivah/mergesort.scala
Last active Oct 30, 2018

Embed
What would you like to do?
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
You can’t perform that action at this time.