File tree Expand file tree Collapse file tree 1 file changed +2
-6
lines changed Expand file tree Collapse file tree 1 file changed +2
-6
lines changed Original file line number Diff line number Diff line change @@ -59,9 +59,7 @@ def perc_up(self, i):
59
59
while i // 2 > 0 :
60
60
if self .heap [i ] < self .heap [i // 2 ]:
61
61
# Swap value of child with value of its parent
62
- tmp = self .heap [i ]
63
- self .heap [i ] = self .heap [i // 2 ]
64
- self .heap [i // 2 ] = tmp
62
+ self .heap [i ], self .heap [i // 2 ] = self .heap [i // 2 ], self .heap [i ]
65
63
i = i // 2
66
64
67
65
"""
@@ -95,9 +93,7 @@ def perc_down(self, i):
95
93
min_child = self .min_child (i )
96
94
if self .heap [min_child ] < self .heap [i ]:
97
95
# Swap min child with parent
98
- tmp = self .heap [min_child ]
99
- self .heap [min_child ] = self .heap [i ]
100
- self .heap [i ] = tmp
96
+ self .heap [min_child ], self .heap [i ] = self .heap [i ], self .heap [min_child ]
101
97
i = min_child
102
98
"""
103
99
Remove Min method removes the minimum element and swap it with the last
You can’t perform that action at this time.
0 commit comments