def test2(): #rslt = buildUniqueBST(4) rslt = buildBST_dp(4) for t in rslt: BTNode.print_nodes(t) print('--------------') print('==============')
def test2(): post_o = [2, 1] in_o = [2, 1] BTNode.print_nodes(buildT(post_o, in_o)) print('-----------------------------') post_o = [2, 1] in_o = [2, 1] BTNode.print_nodes(buildT(post_o, in_o))
def test3(): n1 = BTNode(1) n2 = BTNode(2) n3 = BTNode(3) n1.right = n2 n2.right = n3 flatten(n1) BTNode.print_nodes(n1)
def test2(): n1 = BTNode(1) n2 = BTNode(2) n3 = BTNode(3) n1.left = n2 n2.left = n3 flatten(n1) BTNode.print_nodes(n1) print('--------------------------')
def test2(): n1 = BTNode(1) n2 = BTNode(2) n2.right = n1 rt = RT() BTNode.print_nodes(n2) print('---------------') rt.rt(n2) BTNode.print_nodes(n2)
def test1(): rslt = buildUniqueBST(3) for t in rslt: BTNode.print_nodes(t) print('--------------') print('==============') rslt = buildBST_dp(3) for t in rslt: BTNode.print_nodes(t) print('--------------') print('==============')
def test1(): n4 = BTNode(4) n2 = BTNode(2) n1 = BTNode(1) n3 = BTNode(3) n7 = BTNode(7) n6 = BTNode(6) n9 = BTNode(9) n4.left = n2 n4.right = n7 n2.left = n1 n2.right = n3 n7.left = n6 n7.right = n9 invertT(n4) BTNode.print_nodes(n4)
def test1(): n1 = BTNode(1) n2 = BTNode(2) n3 = BTNode(3) n4 = BTNode(4) n5 = BTNode(5) n6 = BTNode(6) n4.left = n6 n6.left = n1 n6.right = n3 n4.right = n5 n5.right = n2 rt = RT() BTNode.print_nodes(n4) print('---------------') rt.rt(n4) BTNode.print_nodes(n4) print('==============')
def test1(): n7 = BTNode(7) n10 = BTNode(10) n4 = BTNode(4) n3 = BTNode(3) n1 = BTNode(1) n2 = BTNode(2) n8 = BTNode(8) n11 = BTNode(11) n7.left = n10 n7.right = n2 n10.left = n4 n10.right = n3 n3.right = n1 n2.left = n8 n8.left = n11 BTNode.print_nodes(n7) print('-----------------------------') post_o = [4, 1, 3, 10, 11, 8, 2, 7] in_o = [4, 10, 3, 1, 7, 11, 8, 2] BTNode.print_nodes(buildT(post_o, in_o)) print('-----------------------------') post_o = [4, 1, 3, 10, 11, 8, 2, 7] in_o = [4, 10, 3, 1, 7, 11, 8, 2] BTNode.print_nodes(buildTFaster(post_o, in_o)) print('-----------------------------')
def test1(): n1 = BTNode(1) n2 = BTNode(2) n3 = BTNode(3) n4 = BTNode(4) n5 = BTNode(5) n6 = BTNode(6) n7 = BTNode(7) n8 = BTNode(8) n9 = BTNode(9) n1.left = n2 n2.left = n3 n2.right = n4 n4.left = n5 n4.right = n6 n1.right = n7 n7.left = n8 n7.right = n9 flatten(n1) BTNode.print_nodes(n1) print('--------------------------')
def test3(): l1 = ListNode(1) sol = LinkedListToTree() BTNode.print_nodes(sol.ll2tfaster(l1)) print('-----------------') sol = LinkedListToTree2() BTNode.print_nodes(sol.ll2tfaster2(l1)) print('-----------------') BTNode.print_nodes(ll2t(l1)) print('====================')
def test4(): l1 = ListNode(1) l2 = ListNode(2) l1.next = l2 sol = LinkedListToTree() BTNode.print_nodes(sol.ll2tfaster(l1)) print('-----------------') sol = LinkedListToTree2() BTNode.print_nodes(sol.ll2tfaster2(l1)) print('-----------------') BTNode.print_nodes(ll2t(l1)) print('====================')
def test1(): l1 = ListNode(1) l2 = ListNode(2) l3 = ListNode(3) l4 = ListNode(4) l5 = ListNode(5) l6 = ListNode(6) l1.next = l2 l2.next = l3 l3.next = l4 l4.next = l5 l5.next = l6 sol = LinkedListToTree() BTNode.print_nodes(sol.ll2tfaster(l1)) print('-----------------') sol = LinkedListToTree2() BTNode.print_nodes(sol.ll2tfaster2(l1)) print('-----------------') BTNode.print_nodes(ll2t(l1)) print('====================')
def test1(): arr = [3, 2, 1, 6, 0, 5] BTNode.print_nodes(constructTree(arr))
def test1(): nums = [1, 2, 3, 4, 5, 6, 7, 8] BTNode.print_nodes(a2t(nums))
def test1(): arr = [3,2,1,6,0,5] BTNode.print_nodes(constructTree(arr))