Skip to content

Latest commit

 

History

History
179 lines (124 loc) · 3.5 KB

README.md

File metadata and controls

179 lines (124 loc) · 3.5 KB

Heap

img

what is it

a binary tree where the smallest value is always on the top. used to implement a *priority queue or heap sort

costs

Heap avarage worst
Get Min O(1) O(1)
Remove Min O(log(n)) O(log(n))
Insertion O(1) O(log(n))
Heapsort O(1) O(n*log(n))
Heapify O(n) O(n)
Space O(n) O(n)

operations

insertion
search
deletion
inorder traversal

Inorder traversal can be used to sort the binary tree

preorder traversal

preorder Traversal can be used to copy the binary tree

postorder traversal

postorder Traversal can be used to delete the binary tree

get minimum (recursive)
get minimum (iterative)
get maximum (recursive)
get maximum (iterative)

complete implementation

pros

cons

use cases