Should a 234 tree Nodes link to their parent as well as their children?
When Implementing a 234 tree should the Nodes link to their parent as well as their children or should they link only to their children? I know that how i do it is ultimately up to me. But in practice (in your experience) do they normally link back to their parent?
Re: Should a 234 tree Nodes link to their parent as well as their children?
Re: Should a 234 tree Nodes link to their parent as well as their children?
Sorry I didn't realize cross posting was prohibited, I guess now I know.
Re: Should a 234 tree Nodes link to their parent as well as their children?
When you traverse the tree downwards (i.e. away from the root) you can push the visited nodes on a stack; that way you don't need to keep pointers to the parents when you want to crawl back again (i.e. towards the root). But it doesn't harm to store a parent pointer in each node.
kind regards,
Jos
Re: Should a 234 tree Nodes link to their parent as well as their children?
Quote:
Originally Posted by
JosAH
When you traverse the tree downwards (i.e. away from the root) you can push the visited nodes on a stack; that way you don't need to keep pointers to the parents when you want to crawl back again (i.e. towards the root). But it doesn't harm to store a parent pointer in each node.
kind regards,
Jos
That is next level genius!!!... all joking aside that actually sound like a really good solution. Thanks, I don't think I would of thought of that on my own.