Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • World
  • Users
  • Groups
Skins
  • Light
  • Cerulean
  • Cosmo
  • Flatly
  • Journal
  • Litera
  • Lumen
  • Lux
  • Materia
  • Minty
  • Morph
  • Pulse
  • Sandstone
  • Simplex
  • Sketchy
  • Spacelab
  • United
  • Yeti
  • Zephyr
  • Dark
  • Cyborg
  • Darkly
  • Quartz
  • Slate
  • Solar
  • Superhero
  • Vapor

  • Default (No Skin)
  • No Skin
Collapse
Code Project
  1. Home
  2. General Programming
  3. C / C++ / MFC
  4. Dynamic Tree

Dynamic Tree

Scheduled Pinned Locked Moved C / C++ / MFC
helpdata-structuresperformancetutorialquestion
3 Posts 3 Posters 0 Views 1 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • J Offline
    J Offline
    john5632
    wrote on last edited by
    #1

    Hi Experts, I need your help to solve a problem. Problem is to create a dynamic tree in memory. I have a node with 2 field 1. Self Record Number and 2. Parent Record Number I need to create a hierarchy (Tree) based on above information. Any node can come in any sequence. There is no rule defined for hirerchy. How to set the node at run time so that I can create a correct child-parent hierarchy?

    E N 2 Replies Last reply
    0
    • J john5632

      Hi Experts, I need your help to solve a problem. Problem is to create a dynamic tree in memory. I have a node with 2 field 1. Self Record Number and 2. Parent Record Number I need to create a hierarchy (Tree) based on above information. Any node can come in any sequence. There is no rule defined for hirerchy. How to set the node at run time so that I can create a correct child-parent hierarchy?

      E Offline
      E Offline
      Emilio Garavaglia
      wrote on last edited by
      #2

      The "parent" should point to the parent and the "self" should point to the sibling. But it is a very poor implementation, difficult to walk and maintain (who are the children of a given parent? you should keep a list of the "world" to scan!). Hierarchies normally requires more pointers: - to the parent - to the first child (and eventually to the last) - to the next sibling (and eventually the previous)

      2 bugs found. > recompile ... 65534 bugs found. :doh:

      1 Reply Last reply
      0
      • J john5632

        Hi Experts, I need your help to solve a problem. Problem is to create a dynamic tree in memory. I have a node with 2 field 1. Self Record Number and 2. Parent Record Number I need to create a hierarchy (Tree) based on above information. Any node can come in any sequence. There is no rule defined for hirerchy. How to set the node at run time so that I can create a correct child-parent hierarchy?

        N Offline
        N Offline
        Niklas L
        wrote on last edited by
        #3

        john5632 wrote:

        I have a node with 2 field 1. Self Record Number and 2. Parent Record Number

        You can add your nodes to a vector, a linked list or a map. Then by definition you already have a tree, as long as you keep the constraint of not adding any loops, and keeping a single root node. It all depends on what you want to do with it in the end. If you need fast look-up, then look at Emilios suggestion above. Otherwise, go simple.

        1 Reply Last reply
        0
        Reply
        • Reply as topic
        Log in to reply
        • Oldest to Newest
        • Newest to Oldest
        • Most Votes


        • Login

        • Don't have an account? Register

        • Login or register to search.
        • First post
          Last post
        0
        • Categories
        • Recent
        • Tags
        • Popular
        • World
        • Users
        • Groups