mirror of
https://github.com/krahets/hello-algo.git
synced 2026-07-08 21:46:06 +00:00
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:
@@ -89,7 +89,7 @@
|
||||
[file]{quick_sort}-[class]{quick_sort_median}-[func]{partition}
|
||||
```
|
||||
|
||||
## 尾递归优化
|
||||
## 递归深度优化
|
||||
|
||||
**在某些输入下,快速排序可能占用空间较多**。以完全有序的输入数组为例,设递归中的子数组长度为 $m$ ,每轮哨兵划分操作都将产生长度为 $0$ 的左子数组和长度为 $m - 1$ 的右子数组,这意味着每一层递归调用减少的问题规模非常小(只减少一个元素),递归树的高度会达到 $n - 1$ ,此时需要占用 $O(n)$ 大小的栈帧空间。
|
||||
|
||||
|
||||
Reference in New Issue
Block a user