Bug fixes and improvements. (#1780)

* Fix the "尾递归优化" to "递归深度优化" in quick_sort.

* Update landing pages.

* Sync zh and zh-hant versions.

* Sync zh and zh-hant versions.
This commit is contained in:
Yudong Jin
2025-07-10 06:32:25 +08:00
committed by GitHub
parent 6a4d62449c
commit e8dc4736a2
43 changed files with 173 additions and 165 deletions

View File

@ -96,7 +96,7 @@ class QuickSortMedian {
}
}
/* 快速排序类(递归优化) */
/* 快速排序类(递归深度优化) */
class QuickSortTailCall {
/* 元素交换 */
static void swap(int[] nums, int i, int j) {
@ -120,7 +120,7 @@ class QuickSortTailCall {
return i; // 返回基准数的索引
}
/* 快速排序(递归优化) */
/* 快速排序(递归深度优化) */
public static void quickSort(int[] nums, int left, int right) {
// 子数组长度为 1 时终止
while (left < right) {
@ -150,9 +150,9 @@ public class quick_sort {
QuickSortMedian.quickSort(nums1, 0, nums1.length - 1);
System.out.println("快速排序(中位基准数优化)完成后 nums1 = " + Arrays.toString(nums1));
/* 快速排序(递归优化) */
/* 快速排序(递归深度优化) */
int[] nums2 = { 2, 4, 1, 0, 3, 5 };
QuickSortTailCall.quickSort(nums2, 0, nums2.length - 1);
System.out.println("快速排序(递归优化)完成后 nums2 = " + Arrays.toString(nums2));
System.out.println("快速排序(递归深度优化)完成后 nums2 = " + Arrays.toString(nums2));
}
}