MCPcopy Create free account
hub / github.com/codemistic/Data-Structures-and-Algorithms / build

Method build

Python/SegmentTree.py:6–13  ·  view source on GitHub ↗
(self,ind,low,high)

Source from the content-addressed store, hash-verified

4 self.seg=[0]*(4*len(arr))
5
6 def build(self,ind,low,high): # [low,high] = segment range
7 if low==high:
8 self.seg[ind]=self.arr[low]
9 return
10 mid=(low+high)//2
11 self.build(2*ind+1,low,mid)
12 self.build(2*ind+2,mid+1,high)
13 self.seg[ind]=max(self.seg[2*ind+1],self.seg[2*ind+2]) # changes
14
15 def update(self,ind,low,high,i,val): # i in arr and idx in seg
16 if low==high:

Callers 2

generateKeyMethod · 0.80
SegmentTree.pyFile · 0.80

Calls 1

maxFunction · 0.50

Tested by

no test coverage detected