Solved

can not understand this java program

Posted on 2007-12-04
2
145 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

Announcing the Most Valuable Experts of 2016

MVEs are more concerned with the satisfaction of those they help than with the considerable points they can earn. They are the types of people you feel privileged to call colleagues. Join us in honoring this amazing group of Experts.

Question has a verified solution.

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

Suggested Solutions

Title # Comments Views Activity
eclipse shortcuts 9 54
by zero exception 10 39
How to convert from xls to xlsx using java 7 35
Java: anonymous class 4 16
For customizing the look of your lightweight component and making it look opaque like it was made of plastic.  This tip assumes your component to be of rectangular shape and completely opaque.   (CODE)
This was posted to the Netbeans forum a Feb, 2010 and I also sent it to Verisign. Who didn't help much in my struggles to get my application signed. ------------------------- Start The idea here is to target your cell phones with the correct…
Viewers will learn about the regular for loop in Java and how to use it. Definition: Break the for loop down into 3 parts: Syntax when using for loops: Example using a for loop:
This tutorial will introduce the viewer to VisualVM for the Java platform application. This video explains an example program and covers the Overview, Monitor, and Heap Dump tabs.

816 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

8 Experts available now in Live!

Get 1:1 Help Now