Skip to content

Commit c9a5c1e

Browse files
committed
update mem
1 parent 0f90c5b commit c9a5c1e

File tree

1 file changed

+4
-0
lines changed

1 file changed

+4
-0
lines changed

memory.md

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1329,6 +1329,10 @@ type treapNode struct {
13291329

13301330
可以看到,把 npagesKey 和 spanKey 当作数据的话,treap 就是二叉搜索树。把 priority 当作数据,treap 就是小顶堆。
13311331

1332+
需要另外注意的是,treap 本身是一种时间复杂度随机的数据结构。我们这里说的 log(n) 是“期望”时间复杂度。因为 priority 这个字段本身是用 fastrand 随机生成的。
1333+
1334+
和这种思路类似的还有 skiplist,其层数理论上也是随机的,但在实际应用中,因为这些数据结构采用的是伪随机数生成器,所以理论上极端情况基本上是不会出现的。
1335+
13321336
## 栈内存分配流程
13331337

13341338
```go

0 commit comments

Comments
 (0)