mirror of
https://github.com/TheAlgorithms/Python.git
synced 2025-07-06 10:31:29 +08:00
Enable ruff E741 rule (#11370)
* Enable ruff E741 rule * [pre-commit.ci] auto fixes from pre-commit.com hooks for more information, see https://pre-commit.ci --------- Co-authored-by: pre-commit-ci[bot] <66853113+pre-commit-ci[bot]@users.noreply.github.com>
This commit is contained in:
@ -66,14 +66,14 @@ class MinHeap:
|
||||
# this is min-heapify method
|
||||
def sift_down(self, idx, array):
|
||||
while True:
|
||||
l = self.get_left_child_idx(idx)
|
||||
r = self.get_right_child_idx(idx)
|
||||
left = self.get_left_child_idx(idx)
|
||||
right = self.get_right_child_idx(idx)
|
||||
|
||||
smallest = idx
|
||||
if l < len(array) and array[l] < array[idx]:
|
||||
smallest = l
|
||||
if r < len(array) and array[r] < array[smallest]:
|
||||
smallest = r
|
||||
if left < len(array) and array[left] < array[idx]:
|
||||
smallest = left
|
||||
if right < len(array) and array[right] < array[smallest]:
|
||||
smallest = right
|
||||
|
||||
if smallest != idx:
|
||||
array[idx], array[smallest] = array[smallest], array[idx]
|
||||
|
Reference in New Issue
Block a user