@@ -32,7 +32,7 @@ def __repr__(self) -> str:
32
32
return str (self .h )
33
33
34
34
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"""
36
36
if child_idx > 0 :
37
37
return (child_idx - 1 ) // 2
38
38
return None
@@ -78,7 +78,7 @@ def max_heapify(self, index: int) -> None:
78
78
self .max_heapify (violation )
79
79
80
80
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"""
82
82
self .h = list (collection )
83
83
self .heap_size = len (self .h )
84
84
if self .heap_size > 1 :
@@ -87,14 +87,14 @@ def build_max_heap(self, collection: Iterable[float]) -> None:
87
87
self .max_heapify (i )
88
88
89
89
def max (self ) -> float :
90
- """ return the max in the heap """
90
+ """return the max in the heap"""
91
91
if self .heap_size >= 1 :
92
92
return self .h [0 ]
93
93
else :
94
94
raise Exception ("Empty heap" )
95
95
96
96
def extract_max (self ) -> float :
97
- """ get and remove max from heap """
97
+ """get and remove max from heap"""
98
98
if self .heap_size >= 2 :
99
99
me = self .h [0 ]
100
100
self .h [0 ] = self .h .pop (- 1 )
@@ -108,7 +108,7 @@ def extract_max(self) -> float:
108
108
raise Exception ("Empty heap" )
109
109
110
110
def insert (self , value : float ) -> None :
111
- """ insert a new value into the max heap """
111
+ """insert a new value into the max heap"""
112
112
self .h .append (value )
113
113
idx = (self .heap_size - 1 ) // 2
114
114
self .heap_size += 1
0 commit comments