Solved

can not understand this java program

Posted on 2007-12-04
2
144 Views
Last Modified: 2013-11-23
http://www.cs.fiu.edu/~weiss/dsj2/code/weiss/nonstandard/BinarySearchTree.java---when i run this program it just shows a msg ----but i want to insert data and delete data from this tree....what i have to do? thanks...
0
Comment
Question by:mithunda5011
  • 2
2 Comments
 
LVL 23

Expert Comment

by:cmalakar
ID: 20408858
Main function in the class BinarySearchTree is a simple test program that does the following...

In the first for loop,  it inserts the numbers, multiples of 37, starting from 37, till the number is divisible by 4000.
In Second for loop, Then it removes odd numbers less than 4000 from the tree.
and blah.. blah..

For you if you want to insert the data and remove them..use the insert and remove api's inside the BinarySearchTree class.

Here is the complete code and explanation of BinarySearchTree example...

http://www.java-tips.org/java-se-tips/java.lang/binary-search-tree-implementation-in-java.html
0
 
LVL 23

Accepted Solution

by:
cmalakar earned 500 total points
ID: 20408910
Dont forget, the data you want to insert must have implemented Comparable interface.

Some Sample Code to insert the string object and remove the same string object

public class Test
{
     //To insert a new String into it..
     BinarySearchTree t = new BinarySearchTree( );
     t.insert("SomeString");

     //To remove the same String ..
     t.remove("SomeString");
}
0

Featured Post

Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

For customizing the look of your lightweight component and making it look lucid like it was made of glass. Or: how to make your component more Apple-ish ;) This tip assumes your component to be of rectangular shape and completely opaque. (COD…
After being asked a question last year, I went into one of my moods where I did some research and code just for the fun and learning of it all.  Subsequently, from this journey, I put together this article on "Range Searching Using Visual Basic.NET …
This video teaches viewers about errors in exception handling.
This tutorial explains how to use the VisualVM tool for the Java platform application. This video goes into detail on the Threads, Sampler, and Profiler tabs.

895 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

15 Experts available now in Live!

Get 1:1 Help Now