dhyuti-n/xlcost-variable-roles huggingface dataset:
Python program:
class newNode :
    def __init__ ( self , data ) :
        self . data = data
        self . left = self . right = None
def heighAndSize ( node , size ) :
    if ( node == None ) :
        return 0
    l = heighAndSize ( node . left , size )
    r = heighAndSize ( node . right , size )
    size [ 0 ] += 1
    return l + 1 if ( l > r ) else r + 1
def density ( root ) :
    if ( root == None ) :
        return 0
    size = [ 0 ]
    _height = heighAndSize ( root , size )
    return size [ 0 ] / _height
if __name__ == ' _ _ main _ _ ' :
    root = newNode ( 1 )
    root . left = newNode ( 2 )
    root . right = newNode ( 3 )
    print ( " Density ▁ of ▁ given ▁ binary ▁ tree ▁ is ▁ " , density ( root ) )

Class/struct names: newNode
Python program:
class Node :
    def __init__ ( self , data ) :
        self . data = data
        self . next = None
def printsqrtn ( head ) :
    sqrtn = None
    i = 1
    j = 1
    while ( head != None ) :
        if ( i == j * j ) :
            if ( sqrtn == None ) :
                sqrtn = head
            else :
                sqrtn = sqrtn . next
            j = j + 1
        i = i + 1
        head = head . next
    return sqrtn . data
def print_1 ( head ) :
    while ( head != None ) :
        print ( head . data , end = " ▁ " )
        head = head . next
    print ( " ▁ " )
def push ( head_ref , new_data ) :
    new_node = Node ( 0 )
    new_node . data = new_data
    new_node . next = ( head_ref )
    ( head_ref ) = new_node
    return head_ref
if __name__ == ' _ _ main _ _ ' :
    head = None
    head = push ( head , 40 )
    head = push ( head , 30 )
    head = push ( head , 20 )
    head = push ( head , 10 )
    print ( " Given ▁ linked ▁ list ▁ is : " )
    print_1 ( head )
    print ( " sqrt ( n ) th ▁ node ▁ is ▁ " , printsqrtn ( head ) )

Class/struct names: Node
Python program:
import math
class Node :
    def __init__ ( self , data ) :
        self . data = data
        self . next = None
def newNode ( data ) :
    new_node = Node ( data )
    new_node . data = data
    new_node . next = None
    return new_node
def fractionalNodes ( head , k ) :
    if ( k <= 0 or head == None ) :
        return None
    fractionalNode = None
    i = 0
    temp = head
    while ( temp != None ) :
        if ( i % k == 0 ) :
            if ( fractionalNode == None ) :
                fractionalNode = head
            else :
                fractionalNode = fractionalNode . next
        i = i + 1
        temp = temp . next
    return fractionalNode
def prList ( node ) :
    while ( node != None ) :
        print ( node . data , end = ' ▁ ' )
        node = node . next
if __name__ == ' _ _ main _ _ ' :
    head = newNode ( 1 )
    head . next = newNode ( 2 )
    head . next . next = newNode ( 3 )
    head . next . next . next = newNode ( 4 )
    head . next . next . next . next = newNode ( 5 )
    k = 2
    print ( " List ▁ is " , end = ' ▁ ' )
    prList ( head )
    answer = fractionalNodes ( head , k )
    print ( " Fractional node is " , end = ' ▁ ' )
    print ( answer . data )

Class/struct names: Node
Python program:
import math
class Node :
    def __init__ ( self , data ) :
        self . data = data
        self . next = None
def newNode ( data ) :
    new_node = Node ( data )
    new_node . data = data
    new_node . next = None
    return new_node
def modularNode ( head , k ) :
    if ( k <= 0 or head == None ) :
        return None
    i = 1
    modularNode = None
    temp = head
    while ( temp != None ) :
        if ( i % k == 0 ) :
            modularNode = temp
        i = i + 1
        temp = temp . next
    return modularNode
if __name__ == ' _ _ main _ _ ' :
    head = newNode ( 1 )
    head . next = newNode ( 2 )
    head . next . next = newNode ( 3 )
    head . next . next . next = newNode ( 4 )
    head . next . next . next . next = newNode ( 5 )
    k = 2
    answer = modularNode ( head , k )
    print ( " Modular ▁ node ▁ is " , end = ' ▁ ' )
    if ( answer != None ) :
        print ( answer . data , end = ' ▁ ' )
    else :
        print ( " None " )

Class/struct names: Node
Python program:
class newNode ( ) :
    def __init__ ( self , data ) :
        self . data = data
        self . left = None
        self . right = None
def modifytree ( root ) :
    right = root . right
    rightMost = root
    if ( root . left ) :
        rightMost = modifytree ( root . left )
        root . right = root . left
        root . left = None
    if ( not right ) :
        return rightMost
    rightMost . right = right
    rightMost = modifytree ( right )
    return rightMost
def printpre ( root ) :
    while ( root != None ) :
        print ( root . data , end = " ▁ " )
        root = root . right
if __name__ == ' _ _ main _ _ ' :
    root = newNode ( 10 )
    root . left = newNode ( 8 )
    root . right = newNode ( 2 )
    root . left . left = newNode ( 3 )
    root . left . right = newNode ( 5 )
    modifytree ( root )
    printpre ( root )

Class/struct names: newNode
Python program:
import math
class Node :
    def __init__ ( self , data ) :
        self . data = data
        self . left = None
        self . right = None
def getNode ( data ) :
    newNode = Node ( data )
    newNode . data = data
    newNode . left = None
    newNode . right = None
    return newNode
def LevelOrder ( root , data ) :
    if ( root == None ) :
        root = getNode ( data )
        return root
    if ( data <= root . data ) :
        root . left = LevelOrder ( root . left , data )
    else :
        root . right = LevelOrder ( root . right , data )
    return root
def constructBst ( arr , n ) :
    if ( n == 0 ) :
        return None
    root = None
    for i in range ( 0 , n ) :
        root = LevelOrder ( root , arr [ i ] )
    return root
def inorderTraversal ( root ) :
    if ( root == None ) :
        return None
    inorderTraversal ( root . left )
    print ( root . data , end = " ▁ " )
    inorderTraversal ( root . right )
if __name__ == ' _ _ main _ _ ' :
    arr = [ 7 , 4 , 12 , 3 , 6 , 8 , 1 , 5 , 10 ]
    n = len ( arr )
    root = constructBst ( arr , n )
    print ( " Inorder ▁ Traversal : ▁ " , end = " " )
    root = inorderTraversal ( root )

Index/key variables: i
Iterator variables: i
Class/struct names: Node
Python program:
class newNode ( ) :
    def __init__ ( self , data ) :
        self . data = data
        self . left = None
        self . right = None
def modifytree ( root ) :
    if ( root == None ) :
        return
    nodeStack = [ ]
    nodeStack . append ( root )
    pre = None
    while ( len ( nodeStack ) ) :
        node = nodeStack [ - 1 ]
        nodeStack . pop ( )
        if ( node . right ) :
            nodeStack . append ( node . right )
        if ( node . left ) :
            nodeStack . append ( node . left )
        if ( pre != None ) :
            pre . right = node
        pre = node
def printpre ( root ) :
    while ( root != None ) :
        print ( root . data , end = " ▁ " )
        root = root . right
root = newNode ( 10 )
root . left = newNode ( 8 )
root . right = newNode ( 2 )
root . left . left = newNode ( 3 )
root . left . right = newNode ( 5 )
modifytree ( root )
printpre ( root )

Accumulator variables: nodeStack
Class/struct names: newNode
Python program:
class newNode ( ) :
    def __init__ ( self , data ) :
        self . key = data
        self . left = None
        self . right = None
def createNLevelTree ( arr , n ) :
    root = newNode ( arr [ 0 ] )
    temp = root
    for i in range ( 1 , n ) :
        if ( temp . key > arr [ i ] ) :
            temp . left = newNode ( arr [ i ] )
            temp = temp . left
        else :
            temp . right = newNode ( arr [ i ] )
            temp = temp . right
    return root
def isBST ( root , min , max ) :
    if ( root == None ) :
        return True
    if ( root . key < min or root . key > max ) :
        return False
    return ( isBST ( root . left , min , ( root . key ) - 1 ) and isBST ( root . right , ( root . key ) + 1 , max ) )
def canRepresentNLevelBST ( arr , n ) :
    root = createNLevelTree ( arr , n )
    return isBST ( root , 0 , 2 ** 32 )
arr = [ 512 , 330 , 78 , 11 , 8 ]
n = len ( arr )
if ( canRepresentNLevelBST ( arr , n ) ) :
    print ( " Yes " )
else :
    print ( " No " )

Index/key variables: i
Iterator variables: i
Class/struct names: newNode
Python program:
if __name__ == ' _ _ main _ _ ' :
    arr = [ 5123 , 3300 , 783 , 1111 , 890 ]
    n = len ( arr )
    max = 2147483647
    min = - 2147483648
    flag = True
    for i in range ( 1 , n ) :
        if ( arr [ i ] > arr [ i - 1 ] and arr [ i ] > min and arr [ i ] < max ) :
            min = arr [ i - 1 ]
        elif ( arr [ i ] < arr [ i - 1 ] and arr [ i ] > min and arr [ i ] < max ) :
            max = arr [ i - 1 ]
        else :
            flag = False
            break
    if ( flag ) :
        print ( " Yes " )
    else :
        print ( " No " )

Index/key variables: i
Iterator variables: i
Boolean variables: flag
Python program:
import sys
import math
class Node :
    def __init__ ( self , data ) :
        self . data = data
        self . left = None
        self . right = None
def storeBSTNodes ( root , nodes ) :
    if not root :
        return
    storeBSTNodes ( root . left , nodes )
    nodes . append ( root )
    storeBSTNodes ( root . right , nodes )
def buildTreeUtil ( nodes , start , end ) :
    if start > end :
        return None
    mid = ( start + end ) // 2
    node = nodes [ mid ]
    node . left = buildTreeUtil ( nodes , start , mid - 1 )
    node . right = buildTreeUtil ( nodes , mid + 1 , end )
    return node
def buildTree ( root ) :
    nodes = [ ]
    storeBSTNodes ( root , nodes )
    n = len ( nodes )
    return buildTreeUtil ( nodes , 0 , n - 1 )
def preOrder ( root ) :
    if not root :
        return
    print ( " { } ▁ " . format ( root . data ) , end = " " )
    preOrder ( root . left )
    preOrder ( root . right )
if __name__ == ' _ _ main _ _ ' :
    root = Node ( 10 )
    root . left = Node ( 8 )
    root . left . left = Node ( 7 )
    root . left . left . left = Node ( 6 )
    root . left . left . left . left = Node ( 5 )
    root = buildTree ( root )
    print ( " Preorder ▁ traversal ▁ of ▁ balanced ▁ BST ▁ is ▁ : " )
    preOrder ( root )

Index/key variables: mid
Class/struct names: Node
Python program:
class NodeDetails :
    def __init__ ( self , data , min , max ) :
        self . data = data
        self . min = min
        self . max = max
def levelOrderIsOfBST ( arr , n ) :
    if n == 0 :
        return True
    q = [ ]
    i = 0
    newNode = NodeDetails ( arr [ i ] , INT_MIN , INT_MAX )
    i += 1
    q . append ( newNode )
    while i != n and len ( q ) != 0 :
        temp = q . pop ( 0 )
        if i < n and ( arr [ i ] < temp . data and arr [ i ] > temp . min ) :
            newNode = NodeDetails ( arr [ i ] , temp . min , temp . data )
            i += 1
            q . append ( newNode )
        if i < n and ( arr [ i ] > temp . data and arr [ i ] < temp . max ) :
            newNode = NodeDetails ( arr [ i ] , temp . data , temp . max )
            i += 1
            q . append ( newNode )
    if i == n :
        return True
    return False
if __name__ == " _ _ main _ _ " :
    arr = [ 7 , 4 , 12 , 3 , 6 , 8 , 1 , 5 , 10 ]
    n = len ( arr )
    if levelOrderIsOfBST ( arr , n ) :
        print ( " Yes " )
    else :
        print ( " No " )

Index/key variables: i
Accumulator variables: q
Class/struct names: NodeDetails
Python program:
class Node :
    def __init__ ( self , key ) :
        self . data = key
        self . left = None
        self . right = None
def insert ( root , x ) :
    if ( root == None ) :
        return Node ( x )
    if ( x < root . data ) :
        root . left = insert ( root . left , x )
    elif ( x > root . data ) :
        root . right = insert ( root . right , x )
    return root
def kthSmallest ( root ) :
    global k
    if ( root == None ) :
        return None
    left = kthSmallest ( root . left )
    if ( left != None ) :
        return left
    k -= 1
    if ( k == 0 ) :
        return root
    return kthSmallest ( root . right )
def printKthSmallest ( root ) :
    count = 0
    res = kthSmallest ( root )
    if ( res == None ) :
        print ( " There ▁ are ▁ less ▁ than ▁ k ▁ nodes ▁ in ▁ the ▁ BST " )
    else :
        print ( " K - th ▁ Smallest ▁ Element ▁ is ▁ " , res . data )
if __name__ == ' _ _ main _ _ ' :
    root = None
    keys = [ 20 , 8 , 22 , 4 , 12 , 10 , 14 ]
    for x in keys :
        root = insert ( root , x )
    k = 3
    printKthSmallest ( root )

Iterator variables: x
Class/struct names: Node
Python program:
class newNode :
    def __init__ ( self , x ) :
        self . data = x
        self . left = None
        self . right = None
        self . lCount = 0
def insert ( root , x ) :
    if ( root == None ) :
        return newNode ( x )
    if ( x < root . data ) :
        root . left = insert ( root . left , x )
        root . lCount += 1
    elif ( x > root . data ) :
        root . right = insert ( root . right , x ) ;
    return root
def kthSmallest ( root , k ) :
    if ( root == None ) :
        return None
    count = root . lCount + 1
    if ( count == k ) :
        return root
    if ( count > k ) :
        return kthSmallest ( root . left , k )
    return kthSmallest ( root . right , k - count )
if __name__ == ' _ _ main _ _ ' :
    root = None
    keys = [ 20 , 8 , 22 , 4 , 12 , 10 , 14 ]
    for x in keys :
        root = insert ( root , x )
    k = 4
    res = kthSmallest ( root , k )
    if ( res == None ) :
        print ( " There ▁ are ▁ less ▁ than ▁ k ▁ nodes ▁ in ▁ the ▁ BST " )
    else :
        print ( " K - th ▁ Smallest ▁ Element ▁ is " , res . data )

Iterator variables: x
Class/struct names: newNode
Python program:
class Node :
    def __init__ ( self , x ) :
        self . data = x
        self . left = None
        self . right = None
def buildTree ( inn , pre , inStrt , inEnd ) :
    global preIndex , mp
    if ( inStrt > inEnd ) :
        return None
    curr = pre [ preIndex ]
    preIndex += 1
    tNode = Node ( curr )
    if ( inStrt == inEnd ) :
        return tNode
    inIndex = mp [ curr ]
    tNode . left = buildTree ( inn , pre , inStrt , inIndex - 1 )
    tNode . right = buildTree ( inn , pre , inIndex + 1 , inEnd )
    return tNode
def buldTreeWrap ( inn , pre , lenn ) :
    global mp
    for i in range ( lenn ) :
        mp [ inn [ i ] ] = i
    return buildTree ( inn , pre , 0 , lenn - 1 )
def prInorder ( node ) :
    if ( node == None ) :
        return
    prInorder ( node . left )
    print ( node . data , end = " ▁ " )
    prInorder ( node . right )
if __name__ == ' _ _ main _ _ ' :
    mp = { }
    preIndex = 0
    inn = [ ' D ' , ' B ' , ' E ' , ' A ' , ' F ' , ' C ' ]
    pre = [ ' A ' , ' B ' , ' D ' , ' E ' , ' C ' , ' F ' ]
    lenn = len ( inn )
    root = buldTreeWrap ( inn , pre , lenn )
    print ( " Inorder ▁ traversal ▁ of ▁ " " the ▁ constructed ▁ tree ▁ is " )
    prInorder ( root )

Index/key variables: curr, i, preIndex
Iterator variables: i
Class/struct names: Node
Python program:
def hasOnlyOneChild ( pre , size ) :
    nextDiff = 0 ; lastDiff = 0
    for i in range ( size - 1 ) :
        nextDiff = pre [ i ] - pre [ i + 1 ]
        lastDiff = pre [ i ] - pre [ size - 1 ]
        if nextDiff * lastDiff < 0 :
            return False
    return True
if __name__ == " _ _ main _ _ " :
    pre = [ 8 , 3 , 5 , 7 , 6 ]
    size = len ( pre )
    if ( hasOnlyOneChild ( pre , size ) == True ) :
        print ( " Yes " )
    else :
        print ( " No " )

Index/key variables: i
Iterator variables: i
Python program:
def hasOnlyOneChild ( pre , size ) :
    min = 0 ; max = 0
    if pre [ size - 1 ] > pre [ size - 2 ] :
        max = pre [ size - 1 ]
        min = pre [ size - 2 ]
    else :
        max = pre [ size - 2 ]
        min = pre [ size - 1 ]
    for i in range ( size - 3 , 0 , - 1 ) :
        if pre [ i ] < min :
            min = pre [ i ]
        elif pre [ i ] > max :
            max = pre [ i ]
        else :
            return False
    return True
if __name__ == " _ _ main _ _ " :
    pre = [ 8 , 3 , 5 , 7 , 6 ]
    size = len ( pre )
    if ( hasOnlyOneChild ( pre , size ) ) :
        print ( " Yes " )
    else :
        print ( " No " )

Index/key variables: i
Iterator variables: i
Python program:
class Node :
    def __init__ ( self , data ) :
        self . key = data
        self . left = None
        self . right = None
def KSmallestUsingMorris ( root , k ) :
    count = 0
    ksmall = - 9999999999
    curr = root
    while curr != None :
        if curr . left == None :
            count += 1
            if count == k :
                ksmall = curr . key
            curr = curr . right
        else :
            pre = curr . left
            while ( pre . right != None and pre . right != curr ) :
                pre = pre . right
            if pre . right == None :
                pre . right = curr
                curr = curr . left
            else :
                pre . right = None
                count += 1
                if count == k :
                    ksmall = curr . key
                curr = curr . right
    return ksmall
def insert ( node , key ) :
    if node == None :
        return Node ( key )
    if key < node . key :
        node . left = insert ( node . left , key )
    elif key > node . key :
        node . right = insert ( node . right , key )
    return node
if __name__ == ' _ _ main _ _ ' :
    root = None
    root = insert ( root , 50 )
    insert ( root , 30 )
    insert ( root , 20 )
    insert ( root , 40 )
    insert ( root , 70 )
    insert ( root , 60 )
    insert ( root , 80 )
    for k in range ( 1 , 8 ) :
        print ( KSmallestUsingMorris ( root , k ) , end = " ▁ " )

Accumulator variables: count
Iterator variables: k
Class/struct names: Node
Python program:
def isInorder ( arr , n ) :
    if ( n == 0 or n == 1 ) :
        return True
    for i in range ( 1 , n , 1 ) :
        if ( arr [ i - 1 ] > arr [ i ] ) :
            return False
    return True
if __name__ == ' _ _ main _ _ ' :
    arr = [ 19 , 23 , 25 , 30 , 45 ]
    n = len ( arr )
    if ( isInorder ( arr , n ) ) :
        print ( " Yes " )
    else :
        print ( " No " )

Index/key variables: i
Iterator variables: i
Python program:
class TreeNode :
    def __init__ ( self , x ) :
        self . val = x
        self . left = None
        self . right = None
s = set ( )
st = [ ]
def buildTree ( preorder , inorder , n ) :
    root = None ;
    pre = 0
    in_t = 0
    while pre < n :
        node = None ;
        while True :
            node = TreeNode ( preorder [ pre ] )
            if ( root == None ) :
                root = node ;
            if ( len ( st ) > 0 ) :
                if ( st [ - 1 ] in s ) :
                    s . discard ( st [ - 1 ] ) ;
                    st [ - 1 ] . right = node ;
                    st . pop ( ) ;
                else :
                    st [ - 1 ] . left = node ;
            st . append ( node ) ;
            if pre >= n or preorder [ pre ] == inorder [ in_t ] :
                pre += 1
                break
            pre += 1
        node = None ;
        while ( len ( st ) > 0 and in_t < n and st [ - 1 ] . val == inorder [ in_t ] ) :
            node = st [ - 1 ] ;
            st . pop ( ) ;
            in_t += 1
        if ( node != None ) :
            s . add ( node ) ;
            st . append ( node ) ;
    return root ;
def printInorder ( node ) :
    if ( node == None ) :
        return ;
    printInorder ( node . left ) ;
    print ( node . val , end = " ▁ " ) ;
    printInorder ( node . right ) ;
if __name__ == ' _ _ main _ _ ' :
    in_t = [ 9 , 8 , 4 , 2 , 10 , 5 , 10 , 1 , 6 , 3 , 13 , 12 , 7 ]
    pre = [ 1 , 2 , 4 , 8 , 9 , 5 , 10 , 10 , 3 , 6 , 7 , 12 , 13 ]
    l = len ( in_t )
    root = buildTree ( pre , in_t , l ) ;
    printInorder ( root ) ;

Index/key variables: in_t, pre
Accumulator variables: s, st
Class/struct names: TreeNode
Python program:
class Node :
    def __init__ ( self ) :
        self . val = 0
        self . left = None
        self . right = None
def Node_ ( val1 ) :
    temp = Node ( )
    temp . val = val1
    temp . left = temp . right = None
    return temp
s = { }
def insertToHash ( root ) :
    if ( root == None ) :
        return
    insertToHash ( root . left )
    s . add ( root . data )
    insertToHash ( root . right )
def checkBSTs ( root1 , root2 ) :
    if ( root1 != None and root2 != None ) :
        return True
    if ( ( root1 == None and root2 != None ) or ( root1 != None and root2 == None ) ) :
        return False
    s1 = { }
    s2 = { }
    s = s1
    insertToHash ( root1 )
    s1 = s
    s = s2
    insertToHash ( root2 )
    s2 = s
    return ( s1 == ( s2 ) )
root1 = Node_ ( 15 )
root1 . left = Node_ ( 10 )
root1 . right = Node_ ( 20 )
root1 . left . left = Node_ ( 5 )
root1 . left . right = Node_ ( 12 )
root1 . right . right = Node_ ( 25 )
root2 = Node_ ( 15 )
root2 . left = Node_ ( 12 )
root2 . right = Node_ ( 20 )
root2 . left . left = Node_ ( 5 )
root2 . left . left . right = Node_ ( 10 )
root2 . right . right = Node_ ( 25 )
if ( checkBSTs ( root1 , root2 ) ) :
    print ( " YES " )
else :
    print ( " NO " )

Class/struct names: Node
Python program:
class Node :
    def __init__ ( self ) :
        self . val = 0
        self . left = None
        self . right = None
def Node_ ( val1 ) :
    temp = Node ( )
    temp . val = val1
    temp . left = temp . right = None
    return temp
v = [ ]
def storeInorder ( root ) :
    if ( root == None ) :
        return
    storeInorder ( root . left )
    v . append ( root . data )
    storeInorder ( root . right )
def checkBSTs ( root1 , root2 ) :
    if ( root1 != None and root2 != None ) :
        return True
    if ( ( root1 == None and root2 != None ) or ( root1 != None and root2 == None ) ) :
        return False
    v1 = [ ]
    v2 = [ ]
    v = v1
    storeInorder ( root1 )
    v1 = v
    v = v2
    storeInorder ( root2 )
    v2 = v
    return ( v1 == v2 )
root1 = Node_ ( 15 )
root1 . left = Node_ ( 10 )
root1 . right = Node_ ( 20 )
root1 . left . left = Node_ ( 5 )
root1 . left . right = Node_ ( 12 )
root1 . right . right = Node_ ( 25 )
root2 = Node_ ( 15 )
root2 . left = Node_ ( 12 )
root2 . right = Node_ ( 20 )
root2 . left . left = Node_ ( 5 )
root2 . left . left . right = Node_ ( 10 )
root2 . right . right = Node_ ( 25 )
if ( checkBSTs ( root1 , root2 ) ) :
    print ( " YES " )
else :
    print ( " NO " )

Class/struct names: Node
Python program:
class newNode :
    def __init__ ( self , data ) :
        self . key = data
        self . left = None
        self . right = None
def insert ( root , key ) :
    if root == None :
        root = newNode ( key )
    elif root . key > key :
        root . left = insert ( root . left , key )
    elif root . key < key :
        root . right = insert ( root . right , key )
    return root
def distanceFromRoot ( root , x ) :
    if root . key == x :
        return 0
    elif root . key > x :
        return 1 + distanceFromRoot ( root . left , x )
    return 1 + distanceFromRoot ( root . right , x )
def distanceBetween2 ( root , a , b ) :
    if root == None :
        return 0
    if root . key > a and root . key > b :
        return distanceBetween2 ( root . left , a , b )
    if root . key < a and root . key < b :
        return distanceBetween2 ( root . right , a , b )
    if root . key >= a and root . key <= b :
        return ( distanceFromRoot ( root , a ) + distanceFromRoot ( root , b ) )
def findDistWrapper ( root , a , b ) :
    if a > b :
        a , b = b , a
    return distanceBetween2 ( root , a , b )
if __name__ == ' _ _ main _ _ ' :
    root = None
    root = insert ( root , 20 )
    insert ( root , 10 )
    insert ( root , 5 )
    insert ( root , 15 )
    insert ( root , 30 )
    insert ( root , 25 )
    insert ( root , 35 )
    a , b = 5 , 55
    print ( findDistWrapper ( root , 5 , 35 ) )

Class/struct names: newNode