heap module

class heap.Heap(cap: int)[source]

Bases: object

Heap class.
Available member functions include:
initialising constructor
parent
left
right
insert
min
Heapify
deleteMin
Heapify(root: int) None[source]
Heapify function
Args:
root: index of top node of the heap
deleteMin() None[source]
Delete the minimum value
insert(val: int) None[source]
Insert node into heap
Args:
val: value to insert
left(i: int) int[source]
Find left child of given node
Args:
i: index of node
Return:
int: index of left child
min() int[source]
Find minimum value in heap
Return:
int: the minimum value
-1: if heap is empty
parent(i: int) int[source]
Find parent of given node
Args:
i: index of node
Return:
int: index of parent
right(i: int) int[source]
Find right child of given node
Args:
i: index of node
Return:
int: index of right child