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

Method update

Python/SegmentTree.py:15–25  ·  view source on GitHub ↗
(self,ind,low,high,i,val)

Source from the content-addressed store, hash-verified

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:
17 self.arr[i]=val
18 self.seg[ind]=val
19 return
20 mid=(low+high)//2
21 if low<=i<=mid:
22 self.update(2*ind+1,low,mid,i,val)
23 else:
24 self.update(2*ind+2,mid+1,high,i,val)
25 self.seg[ind]=max(self.seg[2*ind+1],self.seg[2*ind+2])
26
27 def query(self,ind,low,high,l,r): # [l,r] = query range
28 if l<=low and high<=r: # if s range is completely inside q range

Callers 1

SegmentTree.pyFile · 0.45

Calls 1

maxFunction · 0.50

Tested by

no test coverage detected