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

Method left

data_structures/binary_tree/segment_tree.py:14–24  ·  view source on GitHub ↗

Returns the left child index for a given index in a binary tree. >>> s = SegmentTree([1, 2, 3]) >>> s.left(1) 2 >>> s.left(2) 4

(self, idx)

Source from the content-addressed store, hash-verified

12 self.build(1, 0, self.N - 1)
13
14 def left(self, idx):
15 """
16 Returns the left child index for a given index in a binary tree.
17
18 >>> s = SegmentTree([1, 2, 3])
19 >>> s.left(1)
20 2
21 >>> s.left(2)
22 4
23 """
24 return idx * 2
25
26 def right(self, idx):
27 """

Callers 3

buildMethod · 0.95
update_recursiveMethod · 0.95
query_recursiveMethod · 0.95

Calls

no outgoing calls

Tested by

no test coverage detected