binarytree

N

neapolisratio

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

Flo 'Irian' Schaetz

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
 
P

Phi

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

org.apache.commons.collections.list.TreeList

greetings

phi
 
P

Patricia Shanahan

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
 

Ask a Question

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

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,995
Messages
2,570,228
Members
46,818
Latest member
SapanaCarpetStudio

Latest Threads

Top