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

Method _left

data_structures/heap/heap_generic.py:25–28  ·  view source on GitHub ↗

Returns left-child-index of given index if exists else None

(self, i: int)

Source from the content-addressed store, hash-verified

23 return int((i - 1) / 2) if i > 0 else None
24
25 def _left(self, i: int) -> int | None:
26 """Returns left-child-index of given index if exists else None"""
27 left = int(2 * i + 1)
28 return left if 0 < left < self.size else None
29
30 def _right(self, i: int) -> int | None:
31 """Returns right-child-index of given index if exists else None"""

Callers 1

_get_valid_parentMethod · 0.95

Calls

no outgoing calls

Tested by

no test coverage detected