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....
Flo 'Irian' Schaetz - 21 Dec 2006 19:22 GMT
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
Phi - 22 Dec 2006 07:32 GMT
I dont know, if this does it ... but anyway: have a look at the "TreeList".
org.apache.commons.collections.list.TreeList
greetings
phi
> please help me.......:
> i have to implement a binary tree throgh a vector.How can i do?
[quoted text clipped - 14 lines]
> i have the exam next month....and believe me......don't know how to
> save me....
Patricia Shanahan - 22 Dec 2006 15:35 GMT
...
> 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