Implementation of Binary Tree in Android

At this Binary Tree development project,I implemented all features of BTree like inserting a new node,deleting a node,Traversing the tree. Most exhaustive work was to implement the deleting part. Here are the inserting a new node code of the project


public void insertTree(BinaryTree<Integer> bTree,Integer value) {

 if(!bTree.hasValue())
 {
 //bTree= new BinaryTree<Integer>(value);
 bTree.setValue(value);
 //bTree = new BinaryTree<Integer>(value,null,null);
 //DisplayToast("0");
 }
 else
 {
 //DisplayToast(value);
 if(value <= bTree.getValue())
 {
 if(!bTree.hasLeft())
 {
 bTree.setLeft(new BinaryTree<Integer>(value));

 }
 else
 {
 //DisplayToast("10011");
 insertTree(bTree.getLeft(),value);
 }

 }
 else
 {
 if(!bTree.hasRight())
 {
 bTree.setRight(new BinaryTree<Integer>(value));
 }
 else
 {
 insertTree(bTree.getRight(),value);
 //DisplayToast("10022");
 }
 }
 }
 }

Here are some screen-shots of the BinaryTree project. You can find the full code(BinaryTree.rar) at the sidebar(Box widget).

Advertisements

1 Comment

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s