I tried looking high and low for a sample of writing a code for a Binary Tree, there isnt one or i must have missed it somewhere.
This is what i would need in assembly language.
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
;
; 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
;
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
i manage to come out with something in java, but i have no idea how to translate it into assembly (DLX assembly) language.
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
}
Can anyone give me a rough idea or let me know how can i find an assembly equivalent on the internet please? Thanks alot in advance.