data_structures.heap.max_heap

Attributes

binary_heap

Classes

BinaryHeap

A max-heap implementation in Python

Module Contents

class data_structures.heap.max_heap.BinaryHeap

A max-heap implementation in Python >>> binary_heap = BinaryHeap() >>> binary_heap.insert(6) >>> binary_heap.insert(10) >>> binary_heap.insert(15) >>> binary_heap.insert(12) >>> binary_heap.pop() 15 >>> binary_heap.pop() 12 >>> binary_heap.get_list [10, 6] >>> len(binary_heap) 2

__len__()

Length of the array

__swap_down(i: int) None

Swap the element down

__swap_up(i: int) None

Swap the element up

insert(value: int) None

Insert new element

pop() int

Pop the root element

__heap = [0]
__size = 0
property get_list
data_structures.heap.max_heap.binary_heap