mirror of
https://github.com/krahets/hello-algo.git
synced 2024-12-25 02:36:29 +08:00
Update merge_sort.go
This commit is contained in:
parent
1b71e74baa
commit
5d45f71167
1 changed files with 2 additions and 2 deletions
|
@ -25,11 +25,11 @@ func merge(nums []int, left, mid, right int) {
|
|||
if i > left_end {
|
||||
nums[k] = tmp[j]
|
||||
j++
|
||||
// 否则,若“右子数组已全部合并完”或“左子数组元素 < 右子数组元素”,则选取左子数组元素,并且 i++
|
||||
// 否则,若“右子数组已全部合并完”或“左子数组元素 <= 右子数组元素”,则选取左子数组元素,并且 i++
|
||||
} else if j > right_end || tmp[i] <= tmp[j] {
|
||||
nums[k] = tmp[i]
|
||||
i++
|
||||
// 否则,若“左子数组元素 > 右子数组元素”,则选取右子数组元素,并且 j++
|
||||
// 否则,若“左右子数组都未全部合并完”且“左子数组元素 > 右子数组元素”,则选取右子数组元素,并且 j++
|
||||
} else {
|
||||
nums[k] = tmp[j]
|
||||
j++
|
||||
|
|
Loading…
Reference in a new issue