本文整理汇总了Python中btNode.BTNode.left方法的典型用法代码示例。如果您正苦于以下问题:Python BTNode.left方法的具体用法?Python BTNode.left怎么用?Python BTNode.left使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类btNode.BTNode
的用法示例。
在下文中一共展示了BTNode.left方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: test1
# 需要导入模块: from btNode import BTNode [as 别名]
# 或者: from btNode.BTNode import left [as 别名]
def test1():
n15 = BTNode(15)
n7 = BTNode(7)
n30 = BTNode(30)
n11 = BTNode(11)
n9 = BTNode(9)
n8 = BTNode(8)
n10 = BTNode(10)
n14 = BTNode(14)
n13 = BTNode(13)
n12 = BTNode(12)
n15.left = n7
n15.right = n30
n7.right = n11
n11.left = n9
n11.right = n14
n9.left = n8
n9.right = n10
n11.right = n14
n14.left = n13
n13.left = n12
print(lcaBST(n15, n8, n12).val)
print(lcaBST(n15, n13, n12).val)
print(lcaBST(n15, n7, n12).val)
示例2: test1
# 需要导入模块: from btNode import BTNode [as 别名]
# 或者: from btNode.BTNode import left [as 别名]
def test1():
n11 = BTNode(11)
n8 = BTNode(8)
n4 = BTNode(4)
n1 = BTNode(1)
n5 = BTNode(5)
n6 = BTNode(6)
n7 = BTNode(7)
n16 = BTNode(16)
n14 = BTNode(14)
n15 = BTNode(15)
n12 = BTNode(12)
n13 = BTNode(13)
n11.left = n8
n8.left = n4
n4.left = n1
n4.right = n5
n5.right = n6
n6.right = n7
n11.right = n16
n16.left = n14
n14.left = n12
n14.right = n15
n12.right = n13
res = inorderBSTSuccessor(n11, n7)
val = None if not res else res.val
print(val)
print('----------')
res = inorderBSTSuccessor(n11, n12)
val = None if not res else res.val
print(val)
print('=============')
示例3: test1
# 需要导入模块: from btNode import BTNode [as 别名]
# 或者: from btNode.BTNode import left [as 别名]
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)
n10 = BTNode(10)
n11 = BTNode(11)
n1.left = n2
n1.right = n3
n2.left = n4
n2.right = n5
n4.left = n6
n4.right = n7
n3.left = n8
n3.right = n9
n8.left = n10
n8.right = n11
print(pot(n1))
print(pot_stack(n1))
示例4: test1
# 需要导入模块: from btNode import BTNode [as 别名]
# 或者: from btNode.BTNode import left [as 别名]
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('-----------------------------')
示例5: test2
# 需要导入模块: from btNode import BTNode [as 别名]
# 或者: from btNode.BTNode import left [as 别名]
def test2():
n1 = BTNode(1)
n2 = BTNode(2)
n3 = BTNode(3)
n4 = BTNode(4)
n1.left = n2
n2.left = n3
n3.left = n4
print(isBalBST(n1))
示例6: test1
# 需要导入模块: from btNode import BTNode [as 别名]
# 或者: from btNode.BTNode import left [as 别名]
def test1():
n3 = BTNode(3)
n9 = BTNode(9)
n20 = BTNode(20)
n15 = BTNode(15)
n7 = BTNode(7)
n3.left = n9
n3.right = n20
n20.left = n15
n20.right = n7
print(zzTrav(n3))
示例7: test2
# 需要导入模块: from btNode import BTNode [as 别名]
# 或者: from btNode.BTNode import left [as 别名]
def test2():
n1 = BTNode(1)
n2 = BTNode(2)
n3 = BTNode(3)
n1.left = n2
n2.left = n3
flatten(n1)
BTNode.print_nodes(n1)
print('--------------------------')
示例8: test3
# 需要导入模块: from btNode import BTNode [as 别名]
# 或者: from btNode.BTNode import left [as 别名]
def test3():
n5 = BTNode(5)
n4 = BTNode(4)
n9 = BTNode(9)
n7 = BTNode(7)
n2 = BTNode(2)
n5.left = n4
n4.left = n9
n9.left = n7
n5.right = n2
print(sumRoot2LeafNumbers(n5))
示例9: test1
# 需要导入模块: from btNode import BTNode [as 别名]
# 或者: from btNode.BTNode import left [as 别名]
def test1():
n1 = BTNode(1)
n2 = BTNode(2)
n3 = BTNode(3)
n4 = BTNode(4)
n1.left = n2
n1.right = n3
n2.left = n4
print(constructStr(n1))
print(constructStr2_top(n1))
示例10: test1
# 需要导入模块: from btNode import BTNode [as 别名]
# 或者: from btNode.BTNode import left [as 别名]
def test1():
n3 = BTNode(3)
n9 = BTNode(9)
n20 = BTNode(20)
n15 = BTNode(15)
n7 = BTNode(7)
n3.left = n9
n3.right = n20
n20.left = n15
n20.right = n7
lst = []
lot(n3, 0, lst)
print(lst)
示例11: test1
# 需要导入模块: from btNode import BTNode [as 别名]
# 或者: from btNode.BTNode import left [as 别名]
def test1():
n1 = BTNode(1)
n2 = BTNode(2)
n3 = BTNode(3)
n4 = BTNode(4)
n5 = BTNode(5)
n6 = BTNode(6)
n3.left = n2
n3.right = n5
n2.left = n1
n5.left = n4
n5.right = n6
print(isBalBST(n3))
示例12: test2
# 需要导入模块: from btNode import BTNode [as 别名]
# 或者: from btNode.BTNode import left [as 别名]
def test2():
n1 = BTNode(1)
n2 = BTNode(2)
n3 = BTNode(3)
n4 = BTNode(4)
n5 = BTNode(5)
n1.left = n2
n2.right = n3
n3.right = n4
n4.left = n5
lst = []
lot(n1, 0, lst)
print(lst)
示例13: test1
# 需要导入模块: from btNode import BTNode [as 别名]
# 或者: from btNode.BTNode import left [as 别名]
def test1():
n1 = BTNode(1)
n2 = BTNode(2)
n5 = BTNode(5)
n7 = BTNode(7)
n9 = BTNode(9)
n8 = BTNode(8)
n1.left = n2
n2.left = n5
n2.right = n9
n5.left = n7
n9.left = n8
print(rightView(n1))
示例14: test2
# 需要导入模块: from btNode import BTNode [as 别名]
# 或者: from btNode.BTNode import left [as 别名]
def test2():
n1 = BTNode(1)
n2 = BTNode(2)
n1.left = n2
print(pathSum(n1, 0, 1))
print(pathSumAlt(n1, 1))
示例15: buildTHelper
# 需要导入模块: from btNode import BTNode [as 别名]
# 或者: from btNode.BTNode import left [as 别名]
def buildTHelper(post_o, in_o, idx_dic, beg, end):
if beg < end:
mid = idx_dic[post_o.pop()]
n = BTNode(in_o[mid])
n.right = buildTHelper(post_o, in_o, idx_dic, mid+1, end)
n.left = buildTHelper(post_o, in_o, idx_dic, beg, mid)
return n