當前位置: 首頁>>代碼示例>>Python>>正文


Python BTNode.right方法代碼示例

本文整理匯總了Python中btNode.BTNode.right方法的典型用法代碼示例。如果您正苦於以下問題:Python BTNode.right方法的具體用法?Python BTNode.right怎麽用?Python BTNode.right使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在btNode.BTNode的用法示例。


在下文中一共展示了BTNode.right方法的15個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Python代碼示例。

示例1: test1

# 需要導入模塊: from btNode import BTNode [as 別名]
# 或者: from btNode.BTNode import right [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))
開發者ID:victorfei,項目名稱:interview,代碼行數:27,代碼來源:preorderTrav.py

示例2: test1

# 需要導入模塊: from btNode import BTNode [as 別名]
# 或者: from btNode.BTNode import right [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('-----------------------------')
開發者ID:victorfei,項目名稱:interview,代碼行數:32,代碼來源:buildTreePostInorder.py

示例3: test1

# 需要導入模塊: from btNode import BTNode [as 別名]
# 或者: from btNode.BTNode import right [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)
開發者ID:victorfei,項目名稱:interview,代碼行數:27,代碼來源:lowestCommonAncesBST.py

示例4: test3

# 需要導入模塊: from btNode import BTNode [as 別名]
# 或者: from btNode.BTNode import right [as 別名]
def test3():
    n1 = BTNode(1)
    n2 = BTNode(2)
    n3 = BTNode(3)

    n1.right = n2
    n2.right = n3

    flatten(n1)
    BTNode.print_nodes(n1)
開發者ID:victorfei,項目名稱:interview,代碼行數:12,代碼來源:treeToLinkedList.py

示例5: test1

# 需要導入模塊: from btNode import BTNode [as 別名]
# 或者: from btNode.BTNode import right [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))
開發者ID:victorfei,項目名稱:interview,代碼行數:13,代碼來源:zigZagTraverse.py

示例6: test2

# 需要導入模塊: from btNode import BTNode [as 別名]
# 或者: from btNode.BTNode import right [as 別名]
def test2():
    n1 = BTNode(1)
    n2 = BTNode(2)
    n3 = BTNode(3)
    n4 = BTNode(4)

    n1.left = n2
    n2.right = n4
    n1.right = n3
    print(constructStr(n1))
    print(constructStr2_top(n1))
開發者ID:victorfei,項目名稱:interview,代碼行數:13,代碼來源:stringFromBinaryTree.py

示例7: test2

# 需要導入模塊: from btNode import BTNode [as 別名]
# 或者: from btNode.BTNode import right [as 別名]
def test2():
    n1 = BTNode(1)
    n2 = BTNode(2)
    n3 = BTNode(3)
    n4 = BTNode(4)

    n1.right = n2
    n2.right = n3
    n3.right = n4

    print(postOrderT(n1))
    print(postOrderT_r(n1))
    print(postOrderT_Alt_r(n1))
開發者ID:victorfei,項目名稱:interview,代碼行數:15,代碼來源:postOrderTrav.py

示例8: test1

# 需要導入模塊: from btNode import BTNode [as 別名]
# 或者: from btNode.BTNode import right [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)
開發者ID:victorfei,項目名稱:interview,代碼行數:16,代碼來源:levelOrderTraversal.py

示例9: test1

# 需要導入模塊: from btNode import BTNode [as 別名]
# 或者: from btNode.BTNode import right [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))
開發者ID:victorfei,項目名稱:interview,代碼行數:17,代碼來源:isBSTBalanced.py

示例10: test2

# 需要導入模塊: from btNode import BTNode [as 別名]
# 或者: from btNode.BTNode import right [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)
開發者ID:victorfei,項目名稱:interview,代碼行數:17,代碼來源:levelOrderTraversal.py

示例11: test2

# 需要導入模塊: from btNode import BTNode [as 別名]
# 或者: from btNode.BTNode import right [as 別名]
def test2():
    n1 = BTNode(1)
    n2 = BTNode(2)
    n3 = BTNode(3)
    n4 = BTNode(4)
    n5 = BTNode(5)
    n6 = BTNode(6)
    n7 = BTNode(7)

    n1.left = n2
    n1.right = n3
    n2.left = n4
    n2.right = n5
    n3.left = n6
    n3.right = n7

    print(sumRoot2LeafNumbers(n1))
開發者ID:victorfei,項目名稱:interview,代碼行數:19,代碼來源:sumRoot2LeafNumbers.py

示例12: buildTHelper

# 需要導入模塊: from btNode import BTNode [as 別名]
# 或者: from btNode.BTNode import right [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
開發者ID:victorfei,項目名稱:interview,代碼行數:10,代碼來源:buildTreePostInorder.py

示例13: test2

# 需要導入模塊: from btNode import BTNode [as 別名]
# 或者: from btNode.BTNode import right [as 別名]
def test2():
    n5 = BTNode(5)
    n2 = BTNode(2)
    nm5 = BTNode(-5)

    n5.left = n2
    n5.right = nm5

    print(mfss(n5))
開發者ID:victorfei,項目名稱:interview,代碼行數:11,代碼來源:mostFreqSubtreeSum.py

示例14: test1

# 需要導入模塊: from btNode import BTNode [as 別名]
# 或者: from btNode.BTNode import right [as 別名]
def test1():
    n1 = BTNode(1)
    n2 = BTNode(2)
    n3 = BTNode(3)
    n4 = BTNode(4)
    n5 = BTNode(5)
    n7 = BTNode(7)

    n1.left = n2
    n1.right = n3
    n2.left = n4
    n2.right = n5
    n5.right = n7
    rslt = []
    inOrderTrav(n1, rslt)
    print(rslt)
    print(inOrderTravRec(n1))
    print("--------------")
開發者ID:victorfei,項目名稱:interview,代碼行數:20,代碼來源:inOrderTrav.py

示例15: test1

# 需要導入模塊: from btNode import BTNode [as 別名]
# 或者: from btNode.BTNode import right [as 別名]
def test1():
    n5 = BTNode(5)
    n2 = BTNode(2)
    nm3 = BTNode(-3)

    n5.left = n2
    n5.right = nm3

    print(mfss(n5))
開發者ID:victorfei,項目名稱:interview,代碼行數:11,代碼來源:mostFreqSubtreeSum.py


注:本文中的btNode.BTNode.right方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。