SegmentTree Build
Question
Build tree: 1.以数组的下标来建立线段树 2.以数值来建立线段树
Thought
Solution
def build(self, start, end, A):
if start > end:
return None
root = SegmentTreeNode(start, end, 0)
if start < end:
mid = (start + end) / 2
root.left = self.build(start, mid, A)
root.right = self.build(mid+1, end, A)
root.count = min(root.left.count, root.right.count)
else:
root.count = A[start]
return root