data_structures.heap.max_heap ============================= .. py:module:: data_structures.heap.max_heap Attributes ---------- .. autoapisummary:: data_structures.heap.max_heap.binary_heap Classes ------- .. autoapisummary:: data_structures.heap.max_heap.BinaryHeap Module Contents --------------- .. py:class:: 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 .. py:method:: __len__() Length of the array .. py:method:: __swap_down(i: int) -> None Swap the element down .. py:method:: __swap_up(i: int) -> None Swap the element up .. py:method:: insert(value: int) -> None Insert new element .. py:method:: pop() -> int Pop the root element .. py:attribute:: __heap :value: [0] .. py:attribute:: __size :value: 0 .. py:property:: get_list .. py:data:: binary_heap