Determines which child has the highest priority by 3 cases
(self, parent)
| 72 | return min |
| 73 | |
| 74 | def favorite(self, parent): |
| 75 | """ |
| 76 | Determines which child has the highest priority by 3 cases |
| 77 | """ |
| 78 | left = self.left_child_idx(parent) |
| 79 | right = self.right_child_idx(parent) |
| 80 | |
| 81 | # case 1: both nodes exist |
| 82 | if left <= self.rear and right <= self.rear: |
| 83 | if self.queue[left] <= self.queue[right]: |
| 84 | return left |
| 85 | else: |
| 86 | return right |
| 87 | # case 2: only left exists |
| 88 | elif left <= self.rear: |
| 89 | return left |
| 90 | # case 3: no children (if left doesn't exist, neither can the right) |
| 91 | else: |
| 92 | return None |
| 93 | |
| 94 | def heapify_down(self): |
| 95 | """ |
no test coverage detected