Trees

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • mia023
    New Member
    • May 2007
    • 89

    Trees

    Hello I just want to ask if trees are implemented in the java API other than the ones defined in the package javax.swing
    I also need a good tutorial on them Please.
  • JosAH
    Recognized Expert MVP
    • Mar 2007
    • 11453

    #2
    Originally posted by mia023
    Hello I just want to ask if trees are implemented in the java API other than the ones defined in the package javax.swing
    I also need a good tutorial on them Please.
    You can have a look at the Swing Tutorial for JTrees and TreeModels. Do you simply
    want to display several trees or is the important part on the manipulation of them?
    There are also TreeMaps and TreeSets. What exactly do you want to do?

    kind regards,

    Jos

    Comment

    • mia023
      New Member
      • May 2007
      • 89

      #3
      Originally posted by JosAH
      You can have a look at the Swing Tutorial for JTrees and TreeModels. Do you simply
      want to display several trees or is the important part on the manipulation of them?
      There are also TreeMaps and TreeSets. What exactly do you want to do?

      kind regards,

      Jos
      I want to manipulate tree for example to use Binary search Trees

      Comment

      • JosAH
        Recognized Expert MVP
        • Mar 2007
        • 11453

        #4
        Originally posted by mia023
        I want to manipulate tree for example to use Binary search Trees
        Binary search trees are already implemented by the classes I mentioned in my
        previous reply. Or do you insist on writing your own binary tree implementation?

        kind regards,

        Jos

        Comment

        • mia023
          New Member
          • May 2007
          • 89

          #5
          Originally posted by JosAH
          Binary search trees are already implemented by the classes I mentioned in my
          previous reply. Or do you insist on writing your own binary tree implementation?

          kind regards,

          Jos
          If I want to implement my own Binary sreach Tree what should I do??

          Comment

          • JosAH
            Recognized Expert MVP
            • Mar 2007
            • 11453

            #6
            Originally posted by mia023
            If I want to implement my own Binary sreach Tree what should I do??
            I'd say: study the topic; design something and implement it. A barebones binary
            tree node might look like this (and then some):

            [code=java]
            public class Node<T> {
            private T data;
            private Node left;
            private Node right;
            //
            public Node(T data) { this(data, null, null); }
            public Node(T data, Node left, Node right) {
            this.data= data;
            this.left= left;
            this.right= right;
            }
            //
            // your methods here ...
            }
            [/code]

            kind regards,

            Jos

            Comment

            • BigDaddyLH
              Recognized Expert Top Contributor
              • Dec 2007
              • 1216

              #7
              Originally posted by mia023
              If I want to implement my own Binary sreach Tree what should I do??
              Musician, climbing into taxi: take me to Carnegie Hall.
              New taxi driver: how you do get to Carnegie Hall?
              Musician: practice, young man, practice.

              Comment

              Working...