Solved

can not understand this java program

Posted on 2007-12-04
2
148 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 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

Free Tool: Site Down Detector

Helpful to verify reports of your own downtime, or to double check a downed website you are trying to access.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

Question has a verified solution.

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

INTRODUCTION Working with files is a moderately common task in Java.  For most projects hard coding the file names, using parameters in configuration files, or using command-line arguments is sufficient.   However, when your application has vi…
Introduction Java can be integrated with native programs using an interface called JNI(Java Native Interface). Native programs are programs which can directly run on the processor. JNI is simply a naming and calling convention so that the JVM (Java…
Viewers learn how to read error messages and identify possible mistakes that could cause hours of frustration. Coding is as much about debugging your code as it is about writing it. Define Error Message: Line Numbers: Type of Error: Break Down…
Viewers will learn about if statements in Java and their use The if statement: The condition required to create an if statement: Variations of if statements: An example using if statements:

695 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