| 70 | self.wait(1) |
| 71 | |
| 72 | class SegmentTreeWhatIs(AlgoScene): |
| 73 | def __init__(self, **kwargs): |
| 74 | super().__init__(**kwargs) |
| 75 | self.datas = np.array([1, 2, 3, 4, 5, 6]) |
| 76 | |
| 77 | def construct(self): |
| 78 | self.start_logo(animate=False) |
| 79 | |
| 80 | self.init_message("线段树是一棵树,从数组进行构造") |
| 81 | |
| 82 | array = AlgoVector(self, self.datas) |
| 83 | array.shift(UP) |
| 84 | self.play(ShowCreation(array)) |
| 85 | self.play(array.to_edge, LEFT) |
| 86 | |
| 87 | tree = AlgoSegTree(self, self.datas) |
| 88 | tree.shift(UP*0.5).scale(0.9) |
| 89 | self.play(ShowCreation(tree)) |
| 90 | self.play(tree.to_edge, RIGHT) |
| 91 | |
| 92 | self.show_message("问题规约:给你一个数组,将数组元素放到叶子节点,父节点为左右子树的和") |
| 93 | # |
| 94 | self.wait() |
| 95 | |
| 96 | class SegmentTreeBase(AlgoScene): |
| 97 | def __init__(self, **kwargs): |
nothing calls this directly
no outgoing calls
no test coverage detected