예제 #1
0
 def read2(self):
     maker = Solution()
     while True:
         pre_o, in_o = (yield)
         root = maker.buildTree(pre_o, in_o)
         tree = TaskTree(root)
         self.add(tree)
예제 #2
0
    def test_something(self):
        sol = Solution()
        ans2 = sol.buildTree([7,-10,-4,3,-1,2,-8,11], [-4,-10,3,-1,7,11,-8,2])
        ans = sol.buildTree([3, 9, 20, 15, 7], [9, 3, 15, 20, 7])

        ans3 = "a"
예제 #3
0
                return
            else:
                yield from _iter_(node.down)
                yield node.value
                yield from _iter_(node.right)

        yield from _iter_(self.head)

    def print(self):
        print(f'Preorder: {[a for a in self.preorder()]}')
        print(f'Inorder: {[a for a in self.inorder()]}')

    # ---- future ---- #
    def index_from(self, TreeIO):
        candidates = [a for a in self.inorder()]
        candidates = set(candidates)
        new = [candidates in TreeIO.morphemes]
        self.morphemes.add(new)


if __name__ == '__main__':
    #a = TaskTree()
    pre_o = ['id', 'doc', 'pid', 'bc', 'ssn', 'pr', 'dmv']
    in_o = ['bc', 'ssn', 'pid', 'pr', 'doc', 'dmv', 'id']

    test = Solution()
    res = test.buildTree(pre_o, in_o)

    t_tree = TaskTree(res)
    t_tree.print()