MCPcopy Create free account
hub / github.com/TheAlgorithms/Python / decrease_key

Method decrease_key

data_structures/heap/min_heap.py:126–132  ·  view source on GitHub ↗
(self, node, new_value)

Source from the content-addressed store, hash-verified

124 return len(self.heap) == 0
125
126 def decrease_key(self, node, new_value):
127 assert self.heap[self.idx_of_element[node]].val > new_value, (
128 "newValue must be less that current value"
129 )
130 node.val = new_value
131 self.heap_dict[node.name] = new_value
132 self.sift_up(self.idx_of_element[node])
133
134
135# USAGE

Callers 1

min_heap.pyFile · 0.45

Calls 1

sift_upMethod · 0.95

Tested by

no test coverage detected