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

Method right

data_structures/binary_tree/segment_tree.py:26–36  ·  view source on GitHub ↗

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

(self, idx)

Source from the content-addressed store, hash-verified

24 return idx * 2
25
26 def right(self, idx):
27 """
28 Returns the right child index for a given index in a binary tree.
29
30 >>> s = SegmentTree([1, 2, 3])
31 >>> s.right(1)
32 3
33 >>> s.right(2)
34 5
35 """
36 return idx * 2 + 1
37
38 def build(self, idx, left, right):
39 if left == right:

Callers 3

buildMethod · 0.95
update_recursiveMethod · 0.95
query_recursiveMethod · 0.95

Calls

no outgoing calls

Tested by

no test coverage detected