Results 1 to 16 of 16

Thread: binary tree

  1. #1
    Dedo is offline Newbies
    Join Date
    May 2011
    Posts
    7
    Rep Power
    0

    Default 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:
    Java 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]
    Last edited by DarrylBurke; 05-26-2011 at 11:27 AM.

  2. #2
    Norm's Avatar
    Norm is offline Moderator
    Join Date
    Jun 2008
    Location
    Eastern Florida
    Posts
    17,902
    Rep Power
    25

    Default

    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"?

  3. #3
    JosAH's Avatar
    JosAH is online now Moderator
    Join Date
    Sep 2008
    Location
    Voorschoten, the Netherlands
    Posts
    13,784
    Blog Entries
    7
    Rep Power
    21

    Default

    Quote Originally Posted by Norm View Post
    What is an "integer number"?
    e.g. 42

    kindest regards,

    Jos ;-)
    cenosillicaphobia: the fear for an empty beer glass

  4. #4
    Norm's Avatar
    Norm is offline Moderator
    Join Date
    Jun 2008
    Location
    Eastern Florida
    Posts
    17,902
    Rep Power
    25

    Default

    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.
    Last edited by Norm; 05-26-2011 at 04:53 PM.

  5. #5
    Dedo is offline Newbies
    Join Date
    May 2011
    Posts
    7
    Rep Power
    0

    Default

    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

  6. #6
    JosAH's Avatar
    JosAH is online now Moderator
    Join Date
    Sep 2008
    Location
    Voorschoten, the Netherlands
    Posts
    13,784
    Blog Entries
    7
    Rep Power
    21

    Default

    Quote Originally Posted by Norm View Post
    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
    cenosillicaphobia: the fear for an empty beer glass

  7. #7
    Tolls is offline Moderator
    Join Date
    Apr 2009
    Posts
    12,224
    Rep Power
    20

    Default

    Ow.
    That hurt my brain.

  8. #8
    Norm's Avatar
    Norm is offline Moderator
    Join Date
    Jun 2008
    Location
    Eastern Florida
    Posts
    17,902
    Rep Power
    25

    Default

    @Dedo
    I guess your last post makes sense.

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

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

  9. #9
    Norm's Avatar
    Norm is offline Moderator
    Join Date
    Jun 2008
    Location
    Eastern Florida
    Posts
    17,902
    Rep Power
    25

    Default

    @Dedo
    I guess your last post makes sense.

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

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

  10. #10
    JosAH's Avatar
    JosAH is online now Moderator
    Join Date
    Sep 2008
    Location
    Voorschoten, the Netherlands
    Posts
    13,784
    Blog Entries
    7
    Rep Power
    21

    Default

    Quote Originally Posted by Tolls View Post
    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
    cenosillicaphobia: the fear for an empty beer glass

  11. #11
    Dedo is offline Newbies
    Join Date
    May 2011
    Posts
    7
    Rep Power
    0

    Default

    Quote Originally Posted by Norm View Post
    @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!

  12. #12
    Dedo is offline Newbies
    Join Date
    May 2011
    Posts
    7
    Rep Power
    0

    Default

    I can not see my posts ، ًWhere are they?

  13. #13
    Norm's Avatar
    Norm is offline Moderator
    Join Date
    Jun 2008
    Location
    Eastern Florida
    Posts
    17,902
    Rep Power
    25

    Default

    You can drop the statment about integer
    Can you restate your problem?
    The original post said the problem was with integer numbers.

  14. #14
    Dedo is offline Newbies
    Join Date
    May 2011
    Posts
    7
    Rep Power
    0

    Default

    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...

  15. #15
    Norm's Avatar
    Norm is offline Moderator
    Join Date
    Jun 2008
    Location
    Eastern Florida
    Posts
    17,902
    Rep Power
    25

    Default

    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".

  16. #16
    Norm's Avatar
    Norm is offline Moderator
    Join Date
    Jun 2008
    Location
    Eastern Florida
    Posts
    17,902
    Rep Power
    25

    Default

    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".

Similar Threads

  1. binary tree
    By ryamz in forum New To Java
    Replies: 2
    Last Post: 08-12-2010, 03:45 AM
  2. Replies: 0
    Last Post: 04-04-2010, 08:40 AM
  3. Binary Tree
    By MuslimCoder in forum New To Java
    Replies: 8
    Last Post: 11-19-2009, 06:57 PM
  4. Binary Search Tree
    By michael_mke in forum New To Java
    Replies: 3
    Last Post: 12-04-2008, 03:03 AM

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •