Win a copy of Svelte and Sapper in Action this week in the JavaScript forum!
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Ron McLeod
  • Paul Clapham
  • Bear Bibeault
  • Junilu Lacar
Sheriffs:
  • Jeanne Boyarsky
  • Tim Cooke
  • Henry Wong
Saloon Keepers:
  • Tim Moores
  • Stephan van Hulst
  • Tim Holloway
  • salvin francis
  • Frits Walraven
Bartenders:
  • Scott Selikoff
  • Piet Souris
  • Carey Brown

Trees with arbitrary node pointers

 
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.
 
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();
 
Wanderer
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:
 
There are 10 kinds of people in this world. Those that understand binary get this tiny ad:
the value of filler advertising in 2020
https://coderanch.com/t/730886/filler-advertising
    Bookmark Topic Watch Topic
  • New Topic