Search
 
SCRIPT & CODE EXAMPLE
 
CODE EXAMPLE FOR PYTHON

insert key in binary tree recursively

def insert(node, key, value):
    if node == None:
        node = key
    if node < key:
        insert(node.right, key, value)
    else:
        insert(node.left, key.value)
 
OR 

def insert(node, key, value):
    if node == None:
        node = newNode(key,value)
    elif node > key:
        node.left = insert(node.left, key, value)
    else:
        node.right = insert(node.right, key, value)
    return node
 
PREVIOUS NEXT
Tagged: #insert #key #binary #tree #recursively
ADD COMMENT
Topic
Name
7+8 =