Skip to content

Commit

Permalink
Merge pull request kdn251#51 from yangshun/fix-heap
Browse files Browse the repository at this point in the history
Fix Heap time complexities
  • Loading branch information
kdn251 authored Sep 17, 2017
2 parents 5c495dd + 5b5b34c commit d0614d0
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 8 deletions.
6 changes: 2 additions & 4 deletions README-zh-cn.md
Original file line number Diff line number Diff line change
Expand Up @@ -118,11 +118,9 @@
### Heap
* 堆是一种特殊的基于树的满足某些特性的数据结构,整个堆中的所有父子节点的键值都会满足相同的排序条件。堆更准确地可以分为最大堆与最小堆,在最大堆中,父节点的键值永远大于或者等于子节点的值,并且整个堆中的最大值存储于根节点;而最小堆中,父节点的键值永远小于或者等于其子节点的键值,并且整个堆中的最小值存储于根节点。
* 时间复杂度:
* 访问: `O(log(n))`
* 搜索: `O(log(n))`
* 访问最大值 / 最小值: `O(1)`
* 插入: `O(log(n))`
* 移除: `O(log(n))`
* 移除最大值 / 最小值: `O(1)`
* 移除最大值 / 最小值: `O(log(n))`

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

Expand Down
6 changes: 2 additions & 4 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -136,11 +136,9 @@ A heap can be classified further as either a "max heap" or a "min heap". In a ma
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
or equal to those of the children and the lowest key is in the root node
* Time Complexity:
* Access: `O(log(n))`
* Search: `O(log(n))`
* Access Max / Min: `O(1)`
* Insert: `O(log(n))`
* Remove: `O(log(n))`
* Remove Max / Min: `O(1)`
* Remove Max / Min: `O(log(n))`

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

Expand Down

0 comments on commit d0614d0

Please sign in to comment.