Please clear this doubt relating to Forest (DataStructures)

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • sathishc58
    New Member
    • Sep 2007
    • 34

    Please clear this doubt relating to Forest (DataStructures)

    Hi All

    I recently studied about "Forest" Datastructures.

    Supposed we have two trees. Could not represent diagramatically

    Tree a
    ======
    1) 10 is the root node
    2) 9 is the

    Tree a Tree b
    ===== =====
    10 5
    / \ / \
    9 20 4 7

    These are my doubts

    1) Is forest applicable for General trees.

    2) I read that in "Forest" second tree(Tree b) will be attached as a right child to the first tree (Tree a)

    3) How can I attach "Tree b" to "Tree a".
    Should I make RIGHT CHILD of node "20" of "Tree a" to point to "Tree b".

    4) If I do like that then it violates the binary trees basic principle.
    As node "5" of Tree b is less that node "20" of Tree a.


    Please clarify my doubts.


    Thanks & Regards
    Sathish Kumar
  • weaknessforcats
    Recognized Expert Expert
    • Mar 2007
    • 9214

    #2
    Not all trees are ordered the same way. Some trees are not ordered at all. A forest is just a tree of trees and you are probably only interested in the edges.

    I did a Google on forest data structure and found 248,000 web pages. I expect your answer is there.

    Comment

    • JosAH
      Recognized Expert MVP
      • Mar 2007
      • 11453

      #3
      Originally posted by weaknessforcats
      Not all trees are ordered the same way. Some trees are not ordered at all. A forest is just a tree of trees and you are probably only interested in the edges.
      No, a forest is a set of trees. They don't need to be connected in a single tree.
      Look here.

      kind regards,

      Jos

      Comment

      Working...