Solved

can not understand this java program

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

What Is Threat Intelligence?

Threat intelligence is often discussed, but rarely understood. Starting with a precise definition, along with clear business goals, is essential.

Join & Write a Comment

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…
Introduction This article is the first of three articles that explain why and how the Experts Exchange QA Team does test automation for our web site. This article explains our test automation goals. Then rationale is given for the tools we use to a…
Viewers learn about the scanner class in this video and are introduced to receiving user input for their programs. Additionally, objects, conditional statements, and loops are used to help reinforce the concepts. Introduce Scanner class: Importing…
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:

747 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

10 Experts available now in Live!

Get 1:1 Help Now