Thread: How to program a data tree? (not binary)

1. How to program a data tree? (not binary)

I've seen a lot of tutorials about creating binary trees, but nothing about general data trees (where the number of branches is not limited), could someone explain one or post a link?

Thanks a lot!

2. very simple actually.... In a binary tree you have two pointers that could be filled with a branch. In an n-tree you just need a list of branches at each node. linked list or vector should suit you just fine.

3. So a data tree is a linked list of pointers to nodes, and each node is a linked list to other nodes, etc?

4. Also, what are some accepted methods for traversing a data tree? I assume it can only be done in one direction. Iterators?

5. depends on what it's used for I suppose. Octal tree for instance (8 children per node) is used for color palette optimization and each index represents a specific value for a piece of the RGB value. "traversal" is how you feel like defining it for your given algorithm. Of course you can restrict it to one direction but that depends on what you're doing.

6. There a many different algorithms on general trees: B+, B*, AVL, trie, red black, etc. A good Data Structures text would explain about each of these.

Popular pages Recent additions