This is what i would need in assembly language.
Code:
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; ; ; insert Insert a new node in a binary search tree ; ; ; Entry 0(r14)= ->Pointer to the root of a binary tree ; 4(r14)= Number to be added to the tree ; jal insert ; ; Result r1 = ->Pointer to the root of the binary tree ; ; Uses r1,r2 ; ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
Code:
bst insert(bst tree, int n) // add n to the tree
{
if ( tree == 0 ) // an empty tree is replaced by a new node
{
tree = newNode(n) ;
} else
{
if (n > tree.value) // if n is > node, add n to the left sub-tree
{
tree.left = insert(tree.left,n) ;
} else
{ // otherwise add n to the right sub-tree
tree.right = insert(tree.right,n) ;
}
}
return tree ; // return a pointer to the tree
}

