Efficient trees

H

herbasher

I need a few pointers. It isn't really related to C but I'm not sure
where to post, and thought this group probably has really smart
programmers.

I need to store and manipulate a big tree structure.

What I need is essentially
* variable sized strings organized in a tree, plus
* the ability to iterate through children quickly

This is very vague, although any pointers will help my thought
process. I figured filesystems must have the most advanced
technologies of storing trees (files and directories are stored in
trees), and I looked at ReiserFS/4, but that is just overkill for me,
since all I need is storing strings in a tree, and not files/folders.



Muchas Gracias,
Herb Asher
 
D

Dave Vandervies

I need a few pointers. It isn't really related to C but I'm not sure
where to post, and thought this group probably has really smart
programmers.

comp.programming?


dave
 
M

Malcolm McLean

herbasher said:
I need a few pointers. It isn't really related to C but I'm not sure
where to post, and thought this group probably has really smart
programmers.

I need to store and manipulate a big tree structure.

What I need is essentially
* variable sized strings organized in a tree, plus
* the ability to iterate through children quickly

This is very vague, although any pointers will help my thought
process. I figured filesystems must have the most advanced
technologies of storing trees (files and directories are stored in
trees), and I looked at ReiserFS/4, but that is just overkill for me,
since all I need is storing strings in a tree, and not files/folders.

typedef struct node
{
struct node *next;
struct node *child;
/* optional */ struct node *mother;
char *data;
} NODE;

This is reasonably efficient. Allocate nodes and data strings with malloc().
Non-binary trees can be constructed by having several "next" nodes with
children.
 

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,230
Members
46,819
Latest member
masterdaster

Latest Threads

Top