mirror of
https://github.com/krahets/hello-algo.git
synced 2026-07-10 06:26:08 +00:00
Remove center-table from docs.
Add header to the tables.
This commit is contained in:
@@ -310,8 +310,7 @@
|
||||
给定一组数据,我们考虑使用数组或二叉搜索树存储。
|
||||
|
||||
观察可知,二叉搜索树的各项操作的时间复杂度都是对数阶,具有稳定且高效的性能表现。只有在高频添加、低频查找删除的数据适用场景下,数组比二叉搜索树的效率更高。
|
||||
|
||||
<div class="center-table" markdown>
|
||||
<p align="center"> 表:数组与搜索树的效率对比 </p>
|
||||
|
||||
| | 无序数组 | 二叉搜索树 |
|
||||
| -------- | -------- | ----------- |
|
||||
@@ -319,8 +318,6 @@
|
||||
| 插入元素 | $O(1)$ | $O(\log n)$ |
|
||||
| 删除元素 | $O(n)$ | $O(\log n)$ |
|
||||
|
||||
</div>
|
||||
|
||||
在理想情况下,二叉搜索树是“平衡”的,这样就可以在 $\log n$ 轮循环内查找任意节点。
|
||||
|
||||
然而,如果我们在二叉搜索树中不断地插入和删除节点,可能导致二叉树退化为链表,这时各种操作的时间复杂度也会退化为 $O(n)$ 。
|
||||
|
||||
Reference in New Issue
Block a user