# binary tree

• 05-26-2011, 10:11 AM
Dedo
binary tree
I have binary tree in java to build family members tree.

In add function, I want to determine the parent that will have new child, after that, the user enter the name of new child.

The problem I face is the family tree cannot compare such as the tree has integer numbers.

Is there a method to do this?

This is a main in my code:
Code:

```static public void main(String args[])   {       System.out.println(">>> creating empty tree");       StringBinaryTree t = new StringBinaryTree();       System.out.println(">>> adding elements to the tree");       t.add("lion","");       t.add("shark","r");       t.add("elephant","l");       t.add("zebra","rr");   }```
to more clear :
I want to achieve read the input from the user for the new child .e.g in my code I want to add child for (Zebra) but this child is enter from the user and thanks

[/CODE]
• 05-26-2011, 02:23 PM
Norm
Quote:

the family tree cannot compare such as the tree has integer numbers
Can you explain this with an example of what you want to do and the problem you are having?
What is an "integer number"?
• 05-26-2011, 02:47 PM
JosAH
Quote:

Originally Posted by Norm
What is an "integer number"?

e.g. 42

kindest regards,

Jos ;-)
• 05-26-2011, 03:49 PM
Norm
Or is it "42"? Numeric digits in a String.

Seems redundant. Are integers numbers? What other kinds of numbers are there?

From Wikipedia: negative numbers, rational numbers, irrational numbers, and complex numbers.
• 05-26-2011, 04:28 PM
Dedo
Quote:

Originally Posted by Norm;210979[COLOR="red"
[/COLOR]]Can you explain this with an example of what you want to do and the problem you are having?
What is an "integer number"?

I mean that in family name there is no number such as 1,2, 5,...
instead we have the names of members of the tree,

so, in case want to add new child in family tree,
I want to search about specifc parent (the search by the name of parent) and then insert the new child to this parent.

.e.g. I have a tree consisting of
(John)==>GrandFather
John has two child ( Sami-Devid)

Sami has one child ( Mikal)

How can I search about ( Sami) and then if found ,insert new child (Pel)

when print the tree we found Sami has Mikal and Pel

I hope you understand me
• 05-26-2011, 04:35 PM
JosAH
Quote:

Originally Posted by Norm
Or is it "42"? Numeric digits in a String.

Seems redundant. Are integers numbers? What other kinds of numbers are there?

From Wikipedia: negative numbers, rational numbers, irrational numbers, and complex numbers.

You forgot the quaternions. Noone can do without them ;-)

kind regards,

Jos
• 05-26-2011, 04:53 PM
Tolls
Ow.
That hurt my brain.
• 05-26-2011, 05:02 PM
Norm
@Dedo
I guess your last post makes sense.

I still don't understand where integer numbers fit in.

Quote:

The problem I face is the family tree cannot compare such as the tree has integer numbers.
How does the tree get integer numbers?
• 05-26-2011, 05:02 PM
Norm
@Dedo
I guess your last post makes sense.

I still don't understand where integer numbers fit in.

Quote:

The problem I face is the family tree cannot compare such as the tree has integer numbers.
How does the tree get integer numbers?
• 05-26-2011, 05:22 PM
JosAH
Quote:

Originally Posted by Tolls
Ow.
That hurt my brain.

Think of them as four dimensional vectors with a funny algebra; the properties of them does make them numbers in the mathematical sense. I never used them ...

kind regards,

Jos
• 05-26-2011, 05:46 PM
Dedo
Quote:

Originally Posted by Norm
@Dedo
I guess your last post makes sense.

I still don't understand where integer numbers fit in.

How does the tree get integer numbers?

You can drop the statment about integer if you confuse.

I mean the values of tree are integer number, Just that!
• 05-26-2011, 06:08 PM
Dedo
I can not see my posts ، ًWhere are they?
• 05-26-2011, 08:07 PM
Norm
Quote:

You can drop the statment about integer
The original post said the problem was with integer numbers.
• 05-26-2011, 08:32 PM
Dedo
The original post said that the family names tree not like the tree with integer values because the family names tree need to be string and the compare beteween string not as in integer.

I hope that understand and help me...
• 05-26-2011, 09:10 PM
Norm
Sorry, I still do NOT understand your problem.
integers can be converted to String and "234" can be convered to int.

Can you give me an example of a comparison the would be a problem?

The String "234" can be converted to the int 234. The int 345 can be converted to the String "345".
• 05-26-2011, 09:11 PM
Norm
Sorry, I still do NOT understand your problem.
integers can be converted to String and "234" can be convered to int.

Can you give me an example of a comparison the would be a problem?

The String "234" can be converted to the int 234. The int 345 can be converted to the String "345".