File tree Expand file tree Collapse file tree 1 file changed +3
-3
lines changed Expand file tree Collapse file tree 1 file changed +3
-3
lines changed Original file line number Diff line number Diff line change @@ -21,11 +21,11 @@ def is_empty(self):
21
21
def min_heapify (self , idx ):
22
22
lc = self .left (idx )
23
23
rc = self .right (idx )
24
- if lc < self .cur_size and self .array ( lc ) [0 ] < self .array ( idx ) [0 ]:
24
+ if lc < self .cur_size and self .array [ lc ] [0 ] < self .array [ idx ] [0 ]:
25
25
smallest = lc
26
26
else :
27
27
smallest = idx
28
- if rc < self .cur_size and self .array ( rc ) [0 ] < self .array ( smallest ) [0 ]:
28
+ if rc < self .cur_size and self .array [ rc ] [0 ] < self .array [ smallest ] [0 ]:
29
29
smallest = rc
30
30
if smallest != idx :
31
31
self .swap (idx , smallest )
@@ -43,7 +43,7 @@ def extract_min(self):
43
43
min_node = self .array [0 ][1 ]
44
44
self .array [0 ] = self .array [self .cur_size - 1 ]
45
45
self .cur_size -= 1
46
- self .min_heapify (1 )
46
+ self .min_heapify (0 )
47
47
del self .pos [min_node ]
48
48
return min_node
49
49
You can’t perform that action at this time.
0 commit comments