Skip to content

Commit d0614d0

Browse files
authored
Merge pull request kdn251#51 from yangshun/fix-heap
Fix Heap time complexities
2 parents 5c495dd + 5b5b34c commit d0614d0

File tree

2 files changed

+4
-8
lines changed

2 files changed

+4
-8
lines changed

README-zh-cn.md

+2-4
Original file line numberDiff line numberDiff line change
@@ -118,11 +118,9 @@
118118
### Heap
119119
* 堆是一种特殊的基于树的满足某些特性的数据结构,整个堆中的所有父子节点的键值都会满足相同的排序条件。堆更准确地可以分为最大堆与最小堆,在最大堆中,父节点的键值永远大于或者等于子节点的值,并且整个堆中的最大值存储于根节点;而最小堆中,父节点的键值永远小于或者等于其子节点的键值,并且整个堆中的最小值存储于根节点。
120120
* 时间复杂度:
121-
* 访问: `O(log(n))`
122-
* 搜索: `O(log(n))`
121+
* 访问最大值 / 最小值: `O(1)`
123122
* 插入: `O(log(n))`
124-
* 移除: `O(log(n))`
125-
* 移除最大值 / 最小值: `O(1)`
123+
* 移除最大值 / 最小值: `O(log(n))`
126124

127125
<img src="/Images/heap.png?raw=true" alt="Max Heap" width="400" height="500">
128126

README.md

+2-4
Original file line numberDiff line numberDiff line change
@@ -136,11 +136,9 @@ A heap can be classified further as either a "max heap" or a "min heap". In a ma
136136
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
137137
or equal to those of the children and the lowest key is in the root node
138138
* Time Complexity:
139-
* Access: `O(log(n))`
140-
* Search: `O(log(n))`
139+
* Access Max / Min: `O(1)`
141140
* Insert: `O(log(n))`
142-
* Remove: `O(log(n))`
143-
* Remove Max / Min: `O(1)`
141+
* Remove Max / Min: `O(log(n))`
144142

145143
<img src="/Images/heap.png?raw=true" alt="Max Heap" width="400" height="500">
146144

0 commit comments

Comments
 (0)