Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Commitaf08253

Browse files
authored
Adding Heap time complexities
1 parent5fc33c0 commitaf08253

File tree

1 file changed

+25
-0
lines changed

1 file changed

+25
-0
lines changed

‎src/data-structures/heap/README.md

Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -33,6 +33,31 @@ to the key of `C`
3333
The node at the "top" of the heap with no parents is
3434
called the root node.
3535

36+
##Time Complexities
37+
38+
Here are time complexities of various heap data structures. Function names assume a max-heap.
39+
40+
| Operation| find-max| delete-max| insert| increase-key| meld|
41+
| ---------| --------| ----------| -----| -----------| ----|
42+
|[Binary](https://en.wikipedia.org/wiki/Binary_heap)|`Θ(1)`|`Θ(log n)`|`O(log n)`|`O(log n)`|`Θ(n)`|
43+
|[Leftist](https://en.wikipedia.org/wiki/Leftist_tree)|`Θ(1)`|`Θ(log n)`|`Θ(log n)`|`O(log n)`|`Θ(log n)`|
44+
|[Binomial](https://en.wikipedia.org/wiki/Binomial_heap)|`Θ(1)`|`Θ(log n)`|`Θ(1)`|`O(log n)`|`O(log n)`|
45+
|[Fibonacci](https://en.wikipedia.org/wiki/Fibonacci_heap)|`Θ(1)`|`Θ(log n)`|`Θ(1)`|`Θ(1)`|`Θ(1)`|
46+
|[Pairing](https://en.wikipedia.org/wiki/Pairing_heap)|`Θ(1)`|`Θ(log n)`|`Θ(1)`|`o(log n)`|`Θ(1)`|
47+
|[Brodal](https://en.wikipedia.org/wiki/Brodal_queue)|`Θ(1)`|`Θ(log n)`|`Θ(1)`|`Θ(1)`|`Θ(1)`|
48+
|[Rank-pairing](https://en.wikipedia.org/w/index.php?title=Rank-pairing_heap&action=edit&redlink=1)|`Θ(1)`|`Θ(log n)`|`Θ(1)`|`Θ(1)`|`Θ(1)`|
49+
|[Strict Fibonacci](https://en.wikipedia.org/wiki/Fibonacci_heap)|`Θ(1)`|`Θ(log n)`|`Θ(1)`|`Θ(1)`|`Θ(1)`|
50+
|[2-3 heap](https://en.wikipedia.org/wiki/2%E2%80%933_heap)|`O(log n)`|`O(log n)`|`O(log n)`|`Θ(1)`|`?`|
51+
52+
Where:
53+
-**find-max (or find-min):** find a maximum item of a max-heap, or a minimum item of a min-heap, respectively (a.k.a.*peek*)
54+
-**delete-max (or delete-min):** removing the root node of a max heap (or min heap), respectively
55+
-**insert:** adding a new key to the heap (a.k.a.,*push*)
56+
-**increase-key or decrease-key:** updating a key within a max- or min-heap, respectively
57+
-**meld:** joining two heaps to form a valid new heap containing all the elements of both, destroying the original heaps.
58+
59+
>In this repository, the[MaxHeap.js](./MaxHeap.js) and[MinHeap.js](./MinHeap.js) are examples of the**Binary** heap.
60+
3661
##References
3762

3863
-[Wikipedia](https://en.wikipedia.org/wiki/Heap_(data_structure))

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp