[Rust] Normalize mid calculation in case overflow (#1363)

* Normalize mid calculate in case overflow

* Change ALL language

* Update merge_sort.py

* Update merge_sort.zig

* Update binary_search_tree.zig

* Update binary_search_recur.py

---------

Co-authored-by: Yudong Jin <krahets@163.com>
This commit is contained in:
rongyi
2024-05-18 18:19:19 +08:00
committed by GitHub
parent 0e221540a3
commit 21be3fdaf8
41 changed files with 57 additions and 59 deletions

View File

@ -41,7 +41,7 @@ def merge_sort(nums: list[int], left: int, right: int):
if left >= right:
return # 當子陣列長度為 1 時終止遞迴
# 劃分階段
mid = (left + right) // 2 # 計算中點
mid = left + (right - left) // 2 # 計算中點
merge_sort(nums, left, mid) # 遞迴左子陣列
merge_sort(nums, mid + 1, right) # 遞迴右子陣列
# 合併階段