473,320 Members | 1,926 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,320 software developers and data experts.

Java tree problem!

I need a source code that implements the simple tree approach but each node can adjust for more than 2 childs.Is it possilbe or yet another option available.
Plz provide the module or source code.
Sep 11 '07 #1
2 1343
Nepomuk
3,112 Expert 2GB
I need a source code that implements the simple tree approach but each node can adjust for more than 2 childs.Is it possilbe or yet another option available.
Plz provide the module or source code.
You mean the programming concept of a tree instead of a graphical tree? Check the class TreeList from apache or write your own tree.

If you want to write your own tree, think about what the concept of a tree is. You can have a class Node which is a container class for some data (Strings, Integers, other Objects...) plus it has a Collection (Vector, Array, List, ...) of children (also nodes). It must have a "addChild" method and a "getChild" method, maybe a "search" method or similar,... Depends on what you want.

Try writing it and if you need help, ask here! :-)
Hope that helps.

Greetings,
Nepomuk
Sep 11 '07 #2
JosAH
11,448 Expert 8TB
I need a source code that implements the simple tree approach but each node can adjust for more than 2 childs.Is it possilbe or yet another option available.
Plz provide the module or source code.
Nope, we're not going to give you any source code (you want the code so why
should we build it?). An extremely simple implementation for a general tree node
could be this:

Expand|Select|Wrap|Line Numbers
  1. public class Node {
  2.    private Node child; // ref to first child
  3.    private Node sibling; // ref to next sibling
  4.    private Node parent; // ref to parent;
  5. }
  6.  
All childs of a node can be reached first through the leftmost child reference
and next through the sibling list of that child. The parent reference is optional
but very handy to have.

kind regards,

Jos
Sep 12 '07 #3

Sign in to post your reply or Sign up for a free account.

Similar topics

1
by: novel | last post by:
Hi, i wrote a java program, that create a rdf file parsing a file tree. On the last step the shockwaves and gifs are checked and the byte sizes are written in the rdf file as nodes. The 1....
54
by: Spammay Blockay | last post by:
I've been tasked with doing technical interviews at my company, and I have generally ask a range of OO, Java, and "good programming technique" concepts. However, one of my favorite exercises I...
1
by: David Van D | last post by:
Hi there, A few weeks until I begin my journey towards a degree in Computer Science at Canterbury University in New Zealand, Anyway the course tutors are going to be teaching us JAVA wth bluej...
2
by: Jobs | last post by:
Download the JAVA , .NET and SQL Server interview with answers Download the JAVA , .NET and SQL Server interview sheet and rate yourself. This will help you judge yourself are you really worth of...
15
by: Xah Lee | last post by:
On Java's Interface Xah Lee, 20050223 In Java the language, there's this a keyword “interface”. In a functional language, a function can be specified by its name and parameter specs....
5
blazedaces
by: blazedaces | last post by:
Ok, so you know my problem, java is running out of memory reading with SAX, the event-based xml parser intended more-so than DOM for extremely large files. I'll try to explain what I've been doing...
2
by: astolpho | last post by:
I am using a slightly outdated reference book on J2EE programming. It gives 2 methods of creating a database used in its casestudies. The first is an ANT script that gives the following output: ...
318
by: King Raz | last post by:
The shootout site has benchmarks comparing different languages. It includes C# Mono vs Java but not C# .NET vs Java. So I went through all the benchmark on the site ... ...
2
by: cioccolatina | last post by:
Hey guys, is there anyone who could help me..? I have file ExpressionBinaryTree.java : /** class ExpressionBinaryTree * uses a binary tree to represent binary expressions * does not...
0
by: ryjfgjl | last post by:
ExcelToDatabase: batch import excel into database automatically...
0
by: Vimpel783 | last post by:
Hello! Guys, I found this code on the Internet, but I need to modify it a little. It works well, the problem is this: Data is sent from only one cell, in this case B5, but it is necessary that data...
0
by: jfyes | last post by:
As a hardware engineer, after seeing that CEIWEI recently released a new tool for Modbus RTU Over TCP/UDP filtering and monitoring, I actively went to its official website to take a look. It turned...
0
by: ArrayDB | last post by:
The error message I've encountered is; ERROR:root:Error generating model response: exception: access violation writing 0x0000000000005140, which seems to be indicative of an access violation...
1
by: PapaRatzi | last post by:
Hello, I am teaching myself MS Access forms design and Visual Basic. I've created a table to capture a list of Top 30 singles and forms to capture new entries. The final step is a form (unbound)...
0
by: CloudSolutions | last post by:
Introduction: For many beginners and individual users, requiring a credit card and email registration may pose a barrier when starting to use cloud servers. However, some cloud server providers now...
0
by: Defcon1945 | last post by:
I'm trying to learn Python using Pycharm but import shutil doesn't work
0
by: af34tf | last post by:
Hi Guys, I have a domain whose name is BytesLimited.com, and I want to sell it. Does anyone know about platforms that allow me to list my domain in auction for free. Thank you
0
by: Faith0G | last post by:
I am starting a new it consulting business and it's been a while since I setup a new website. Is wordpress still the best web based software for hosting a 5 page website? The webpages will be...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.