Current location: Hot Scripts Forums » Programming Languages » Other Languages » How to build a binary tree in assembly language?


How to build a binary tree in assembly language?

Reply
  #1 (permalink)  
Old 11-04-08, 08:15 AM
phingphing phingphing is offline
New Member
 
Join Date: Nov 2008
Posts: 1
Thanks: 0
Thanked 0 Times in 0 Posts
Lightbulb How to build a binary tree in assembly language?

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.

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                                      
;                                                           
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
i manage to come out with something in java, but i have no idea how to translate it into assembly (DLX assembly) language.


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
}
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.
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiShare on FacebookShare on Stumble UponShare on Twitter
Reply With Quote
Reply

Bookmarks


Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)
 
Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On

Forum Jump

Similar Threads
Thread Thread Starter Forum Replies Last Post
2-3 Tree implementation ShrpSight Everything Java 2 05-23-09 09:40 AM
assembly language anupamsr Hot Scripts Forum Questions, Suggestions and Feedback 9 12-31-08 11:45 AM
Debounce switch using assembly language Laravinya Other Languages 0 04-29-07 04:37 PM
Assembly Language question jessicayan Other Languages 1 02-13-07 04:07 PM
Assembly language help please psi3000 Other Languages 0 03-25-06 10:21 PM


All times are GMT -5. The time now is 10:32 AM.
vBulletin® Copyright ©2000 - 2012, Jelsoft Enterprises Ltd.