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

Function get_parent_position

graphs/minimum_spanning_tree_prims2.py:18–27  ·  view source on GitHub ↗

heap helper function get the position of the parent of the current node >>> get_parent_position(1) 0 >>> get_parent_position(2) 0

(position: int)

Source from the content-addressed store, hash-verified

16
17
18def get_parent_position(position: int) -> int:
19 """
20 heap helper function get the position of the parent of the current node
21
22 >>> get_parent_position(1)
23 0
24 >>> get_parent_position(2)
25 0
26 """
27 return (position - 1) // 2
28
29
30def get_child_left_position(position: int) -> int:

Callers 2

update_keyMethod · 0.85
_bubble_upMethod · 0.85

Calls

no outgoing calls

Tested by

no test coverage detected