Solved

can not understand this java program

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

Independent Software Vendors: We Want Your Opinion

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

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

Suggested Solutions

Title # Comments Views Activity
xampp tool 12 60
servlet and mdb, jms error 1 57
Is there a simpler dropbox system? 10 44
dao vs facade design patterns 2 37
By the end of 1980s, object oriented programming using languages like C++, Simula69 and ObjectPascal gained momentum. It looked like programmers finally found the perfect language. C++ successfully combined the object oriented principles of Simula w…
Go is an acronym of golang, is a programming language developed Google in 2007. Go is a new language that is mostly in the C family, with significant input from Pascal/Modula/Oberon family. Hence Go arisen as low-level language with fast compilation…
Viewers learn about the third conditional statement “else if” and use it in an example program. Then additional information about conditional statements is provided, covering the topic thoroughly. Viewers learn about the third conditional statement …
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:

726 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