• Post Reply Bookmark Topic Watch Topic
  • New Topic

Trees with arbitrary node pointers  RSS feed

 
Rocky Summers
Ranch Hand
Posts: 66
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hello guys..
how do i make a node class of a tree that has arbitrary pointers (unbounded).
unlike the binary tree, where it only has two pointers (left and right)..
cuz i'm making a spanning tree and it's driving me nuts on how to make the arbitrary pointers.
thanks.
 
Jaap van Hengstum
Greenhorn
Posts: 24
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
You mean something like this?
 
Rocky Summers
Ranch Hand
Posts: 66
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
thank you!
i'll try that out!
 
Rocky Summers
Ranch Hand
Posts: 66
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
hello (again)
i was just wondering what this meant:

i just want to understand..
 
Rocky Summers
Ranch Hand
Posts: 66
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
hi, i tried compiling the code you gave me at home and it worked. but when i tried to compile with the computers here in school, it didnt work.. here's the error:
Node.java:5: incompatible types
found : java.util.ArrayList
required: List
private List nodeList = new ArrayList();
 
Jim Yingst
Wanderer
Sheriff
Posts: 18671
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
"Web": please take a moment to review our display name policy and then edit your display name to something less fictitious-sounding than "Web". Thanks.
As for your question: it looks like there's another class somewhere called List, which is confusing the compiler. You want java.util.List, not a "List" in the default package (which is what your error message indicates). You can either (a) rename the other List class, (b) delete it entirely, or (c) refer to java.util.List by its fully qualified name when that's the one you mean.
[ November 08, 2003: Message edited by: Jim Yingst ]
 
Rocky Summers
Ranch Hand
Posts: 66
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
oh shoot that's right!!! i have a List.java in my directory! ha... ha.... i feel so stupid. thanks!
ok ill change my name.
 
Rocky Summers
Ranch Hand
Posts: 66
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
how would i go about adding more nodes to the tree?
this is my code for the insert:

and this is what i have in my node class:
 
It is sorta covered in the JavaRanch Style Guide.
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!