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

  1. #1
    Registered User
    Join Date
    Aug 2001
    Posts
    244

    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. #2
    pronounced 'fib' FillYourBrain's Avatar
    Join Date
    Aug 2002
    Posts
    2,297
    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.
    "You are stupid! You are stupid! Oh, and don't forget, you are STUPID!" - Dexter

  3. #3
    Registered User
    Join Date
    Aug 2001
    Posts
    244
    So a data tree is a linked list of pointers to nodes, and each node is a linked list to other nodes, etc?

  4. #4
    Registered User
    Join Date
    Aug 2001
    Posts
    244
    Also, what are some accepted methods for traversing a data tree? I assume it can only be done in one direction. Iterators?

  5. #5
    pronounced 'fib' FillYourBrain's Avatar
    Join Date
    Aug 2002
    Posts
    2,297
    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.
    "You are stupid! You are stupid! Oh, and don't forget, you are STUPID!" - Dexter

  6. #6
    CS Author and Instructor
    Join Date
    Sep 2002
    Posts
    511

    Talking

    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.
    Mr. C: Author and Instructor

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. Bitmasking Problem
    By mike_g in forum C++ Programming
    Replies: 13
    Last Post: 11-08-2007, 12:24 AM
  2. Help with Algorithm for inserting data into Binary Tree
    By bcianfrocca in forum C++ Programming
    Replies: 2
    Last Post: 05-09-2005, 04:36 AM
  3. Binary Search Trees Part III
    By Prelude in forum A Brief History of Cprogramming.com
    Replies: 16
    Last Post: 10-02-2004, 03:00 PM
  4. HUGE fps jump
    By DavidP in forum Game Programming
    Replies: 23
    Last Post: 07-01-2004, 10:36 AM
  5. Templated Binary Tree... dear god...
    By Nakeerb in forum C++ Programming
    Replies: 15
    Last Post: 01-17-2003, 02:24 AM