Velocity Reviews - Computer Hardware Reviews

Velocity Reviews > Newsgroups > Programming > Java > binarytree

Reply
Thread Tools

binarytree

 
 
neapolisratio
Guest
Posts: n/a
 
      12-21-2006
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....

 
Reply With Quote
 
 
 
 
Flo 'Irian' Schaetz
Guest
Posts: n/a
 
      12-21-2006
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
 
Reply With Quote
 
 
 
 
Phi
Guest
Posts: n/a
 
      12-22-2006
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....
>

 
Reply With Quote
 
Patricia Shanahan
Guest
Posts: n/a
 
      12-22-2006
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
 
Reply With Quote
 
 
 
Reply

Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
BinaryTree HelpMe Java 8 03-10-2008 05:39 AM



Advertisments
 



1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57