Skip to content

Commit fc6d3e8

Browse files
added comments to mergeSort.swift
1 parent db039b7 commit fc6d3e8

File tree

1 file changed

+2
-0
lines changed

1 file changed

+2
-0
lines changed

sortingAlgo/mergeSort/mergeSort.swift

+2
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
1+
// a function that merges two arrys
12
func merge(_ array_1: inout [Int], _ low: Int, _ mid: Int, _ high: Int) {
23
var i = low
34
var j = mid + 1
@@ -35,6 +36,7 @@ func merge(_ array_1: inout [Int], _ low: Int, _ mid: Int, _ high: Int) {
3536
}
3637
}
3738

39+
// the recursive sorting algorithm that divides the array, sorts the two halves and merges them
3840
func sort(_ array: inout [Int], _ low: Int, _ high: Int) {
3941
if low < high {
4042
let mid = (low + high) / 2

0 commit comments

Comments
 (0)