mercredi 27 juillet 2016

N-ary Tree in C: How to add nodes and store data?

I want to create an n-ary tree composed in this way:

FileFolderTree

Each node has a key, name, type (File/Folder) and URL:

struct node {
    int key;
    char[10] name;
    char[100] url;
    char type;
} node;

Every node can have a different number of child nodes.

I already read about a solution that uses linked lists: N-ary trees in C
But it doesn't say anything about algorithms for adding or accessing nodes.

How can I store my data in a tree like this?
How can I add nodes to the linked list?
How can I access the data once the tree is built?

Aucun commentaire:

Enregistrer un commentaire