binarytree

Discussion in 'Java' started by neapolisratio, Dec 21, 2006.

  1. please help me.......:
    i have to implement a binary tree throgh a vector.How can i do?
    Situation:
    public class VectorBinaryTree<E> implements BinaryTree<E> {
    ..
    ..
    ..
    ..
    ..
    }
    I thinked to use an adaptern pattern like a IndexList<E>
    (ArrayIndexList<E> who implement IndexList<E>), but my binarytree use
    the Position concept, and a vector not.
    How can i override the methods without make wrong?
    my http://ww0.java4.datastructures.net/

    i have the exam next month....and believe me......don't know how to
    save me....
     
    neapolisratio, Dec 21, 2006
    #1
    1. Advertising

  2. And thus spoke neapolisratio...

    > i have to implement a binary tree throgh a vector.How can i do?


    Simply think about where to place each node. Start with the root. Add
    the child-nodes. Add THEIR child-nodes. etc. You'll see that you can
    calculate each node's position in the vector (as long as you assume a
    completly filled binary tree). Use google with "Binary tree array" and
    you'll find something.

    Flo
     
    Flo 'Irian' Schaetz, Dec 21, 2006
    #2
    1. Advertising

  3. neapolisratio

    Phi Guest

    I dont know, if this does it ... but anyway: have a look at the "TreeList".

    org.apache.commons.collections.list.TreeList

    greetings

    phi

    neapolisratio wrote:
    > please help me.......:
    > i have to implement a binary tree throgh a vector.How can i do?
    > Situation:
    > public class VectorBinaryTree<E> implements BinaryTree<E> {
    > .
    > .
    > .
    > .
    > .
    > }
    > I thinked to use an adaptern pattern like a IndexList<E>
    > (ArrayIndexList<E> who implement IndexList<E>), but my binarytree use
    > the Position concept, and a vector not.
    > How can i override the methods without make wrong?
    > my http://ww0.java4.datastructures.net/
    >
    > i have the exam next month....and believe me......don't know how to
    > save me....
    >
     
    Phi, Dec 22, 2006
    #3
  4. neapolisratio wrote:
    ....
    > I thinked to use an adaptern pattern like a IndexList<E>
    > (ArrayIndexList<E> who implement IndexList<E>), but my binarytree use
    > the Position concept, and a vector not.


    Vector has a concept of position. See the get and setElementAt methods.

    Patricia
     
    Patricia Shanahan, Dec 22, 2006
    #4
    1. Advertising

Want to reply to this thread or ask your own question?

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. HelpMe

    BinaryTree

    HelpMe, Mar 9, 2008, in forum: Java
    Replies:
    8
    Views:
    557
    Arved Sandstrom
    Mar 10, 2008
Loading...

Share This Page