@@ -32,7 +32,7 @@ def __repr__(self) -> str:
3232 return str (self .h )
3333
3434 def parent_index (self , child_idx : int ) -> Optional [int ]:
35- """ return the parent index of given child """
35+ """return the parent index of given child"""
3636 if child_idx > 0 :
3737 return (child_idx - 1 ) // 2
3838 return None
@@ -78,7 +78,7 @@ def max_heapify(self, index: int) -> None:
7878 self .max_heapify (violation )
7979
8080 def build_max_heap (self , collection : Iterable [float ]) -> None :
81- """ build max heap from an unsorted array"""
81+ """build max heap from an unsorted array"""
8282 self .h = list (collection )
8383 self .heap_size = len (self .h )
8484 if self .heap_size > 1 :
@@ -87,14 +87,14 @@ def build_max_heap(self, collection: Iterable[float]) -> None:
8787 self .max_heapify (i )
8888
8989 def max (self ) -> float :
90- """ return the max in the heap """
90+ """return the max in the heap"""
9191 if self .heap_size >= 1 :
9292 return self .h [0 ]
9393 else :
9494 raise Exception ("Empty heap" )
9595
9696 def extract_max (self ) -> float :
97- """ get and remove max from heap """
97+ """get and remove max from heap"""
9898 if self .heap_size >= 2 :
9999 me = self .h [0 ]
100100 self .h [0 ] = self .h .pop (- 1 )
@@ -108,7 +108,7 @@ def extract_max(self) -> float:
108108 raise Exception ("Empty heap" )
109109
110110 def insert (self , value : float ) -> None :
111- """ insert a new value into the max heap """
111+ """insert a new value into the max heap"""
112112 self .h .append (value )
113113 idx = (self .heap_size - 1 ) // 2
114114 self .heap_size += 1
0 commit comments