Returns index of valid parent as per desired ordering among given index and both it's children
(self, i: int)
| 47 | return self.arr[i][1] < self.arr[j][1] |
| 48 | |
| 49 | def _get_valid_parent(self, i: int) -> int: |
| 50 | """ |
| 51 | Returns index of valid parent as per desired ordering among given index and |
| 52 | both it's children |
| 53 | """ |
| 54 | left = self._left(i) |
| 55 | right = self._right(i) |
| 56 | valid_parent = i |
| 57 | |
| 58 | if left is not None and not self._cmp(left, valid_parent): |
| 59 | valid_parent = left |
| 60 | if right is not None and not self._cmp(right, valid_parent): |
| 61 | valid_parent = right |
| 62 | |
| 63 | return valid_parent |
| 64 | |
| 65 | def _heapify_up(self, index: int) -> None: |
| 66 | """Fixes the heap in upward direction of given index""" |
no test coverage detected