File tree 2 files changed +4
-8
lines changed
2 files changed +4
-8
lines changed Original file line number Diff line number Diff line change 118
118
### Heap
119
119
* 堆是一种特殊的基于树的满足某些特性的数据结构,整个堆中的所有父子节点的键值都会满足相同的排序条件。堆更准确地可以分为最大堆与最小堆,在最大堆中,父节点的键值永远大于或者等于子节点的值,并且整个堆中的最大值存储于根节点;而最小堆中,父节点的键值永远小于或者等于其子节点的键值,并且整个堆中的最小值存储于根节点。
120
120
* 时间复杂度:
121
- * 访问: ` O(log(n)) `
122
- * 搜索: ` O(log(n)) `
121
+ * 访问最大值 / 最小值: ` O(1) `
123
122
* 插入: ` O(log(n)) `
124
- * 移除: ` O(log(n)) `
125
- * 移除最大值 / 最小值: ` O(1) `
123
+ * 移除最大值 / 最小值: ` O(log(n)) `
126
124
127
125
<img src =" /Images/heap.png?raw=true " alt =" Max Heap " width =" 400 " height =" 500 " >
128
126
Original file line number Diff line number Diff line change @@ -136,11 +136,9 @@ A heap can be classified further as either a "max heap" or a "min heap". In a ma
136
136
than or equal to those of the children and the highest key is in the root node. In a min heap, the keys of parent nodes are less than
137
137
or equal to those of the children and the lowest key is in the root node
138
138
* Time Complexity:
139
- * Access: ` O(log(n)) `
140
- * Search: ` O(log(n)) `
139
+ * Access Max / Min: ` O(1) `
141
140
* Insert: ` O(log(n)) `
142
- * Remove: ` O(log(n)) `
143
- * Remove Max / Min: ` O(1) `
141
+ * Remove Max / Min: ` O(log(n)) `
144
142
145
143
<img src =" /Images/heap.png?raw=true " alt =" Max Heap " width =" 400 " height =" 500 " >
146
144
You can’t perform that action at this time.
0 commit comments