mirror of
https://github.com/krahets/hello-algo.git
synced 2026-06-28 00:24:21 +00:00
Fix toc for the webpage of the chapter of computational complexity (#1107)
* fix the math formula in TOC * Update space_complexity.md * Update time_complexity.md * Update space_complexity.md * Update time_complexity.md --------- Co-authored-by: Yudong Jin <krahets@163.com>
This commit is contained in:
@@ -716,7 +716,7 @@ $$
|
||||
|
||||

|
||||
|
||||
### 常数阶 $O(1)$
|
||||
### 常数阶 $O(1)$ {data-toc-label="常数阶"}
|
||||
|
||||
常数阶常见于数量与输入数据大小 $n$ 无关的常量、变量、对象。
|
||||
|
||||
@@ -726,7 +726,7 @@ $$
|
||||
[file]{space_complexity}-[class]{}-[func]{constant}
|
||||
```
|
||||
|
||||
### 线性阶 $O(n)$
|
||||
### 线性阶 $O(n)$ {data-toc-label="线性阶"}
|
||||
|
||||
线性阶常见于元素数量与 $n$ 成正比的数组、链表、栈、队列等:
|
||||
|
||||
@@ -742,7 +742,7 @@ $$
|
||||
|
||||

|
||||
|
||||
### 平方阶 $O(n^2)$
|
||||
### 平方阶 $O(n^2)$ {data-toc-label="平方阶"}
|
||||
|
||||
平方阶常见于矩阵和图,元素数量与 $n$ 成平方关系:
|
||||
|
||||
@@ -758,7 +758,7 @@ $$
|
||||
|
||||

|
||||
|
||||
### 指数阶 $O(2^n)$
|
||||
### 指数阶 $O(2^n)$ {data-toc-label="指数阶"}
|
||||
|
||||
指数阶常见于二叉树。观察下图,层数为 $n$ 的“满二叉树”的节点数量为 $2^n - 1$ ,占用 $O(2^n)$ 空间:
|
||||
|
||||
@@ -768,7 +768,7 @@ $$
|
||||
|
||||

|
||||
|
||||
### 对数阶 $O(\log n)$
|
||||
### 对数阶 $O(\log n)$ {data-toc-label="对数阶"}
|
||||
|
||||
对数阶常见于分治算法。例如归并排序,输入长度为 $n$ 的数组,每轮递归将数组从中点处划分为两半,形成高度为 $\log n$ 的递归树,使用 $O(\log n)$ 栈帧空间。
|
||||
|
||||
|
||||
Reference in New Issue
Block a user