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

Method query

Python/SegmentTree.py:27–35  ·  view source on GitHub ↗
(self,ind,low,high,l,r)

Source from the content-addressed store, hash-verified

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
29 return self.seg[ind]
30 if high<l or r<low: # if s range is completely outside q range
31 return -float('inf') # changes
32 mid=(low+high)//2
33 left=self.query(2*ind+1,low,mid,l,r)
34 right=self.query(2*ind+2,mid+1,high,l,r)
35 return max(left,right) # changes
36
37
38t=SegmentTree([2,3,1,4,0,7,4,9,3,0])

Callers 1

SegmentTree.pyFile · 0.80

Calls 1

maxFunction · 0.50

Tested by

no test coverage detected