Skip to content

Commit

Permalink
Update SlowSort.swift
Browse files Browse the repository at this point in the history
  • Loading branch information
kelvinlauKL authored Mar 21, 2019
1 parent 81db429 commit 91b7bb1
Showing 1 changed file with 10 additions and 10 deletions.
20 changes: 10 additions & 10 deletions Slow Sort/SlowSort.swift
Original file line number Diff line number Diff line change
Expand Up @@ -7,14 +7,14 @@
//

func slowSort(_ i: Int, _ j: Int, _ numberList: inout [Int]) {
guard if i < j else { return }
let m = (i+j)/2
slowSort(i, m, &numberList)
slowSort(m+1, j, &numberList)
if numberList[j] < numberList[m] {
let temp = numberList[j]
numberList[j] = numberList[m]
numberList[m] = temp
}
slowSort(i, j-1, &numberList)
guard if i < j else { return }
let m = (i+j)/2
slowSort(i, m, &numberList)
slowSort(m+1, j, &numberList)
if numberList[j] < numberList[m] {
let temp = numberList[j]
numberList[j] = numberList[m]
numberList[m] = temp
}
slowSort(i, j-1, &numberList)
}

0 comments on commit 91b7bb1

Please sign in to comment.