MCPcopy Index your code
hub / github.com/OmkarPathak/pygorithm / favorite

Method favorite

pygorithm/data_structures/heap.py:74–92  ·  view source on GitHub ↗

Determines which child has the highest priority by 3 cases

(self, parent)

Source from the content-addressed store, hash-verified

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 """

Callers 1

heapify_downMethod · 0.95

Calls 2

left_child_idxMethod · 0.95
right_child_idxMethod · 0.95

Tested by

no test coverage detected