Reputation: 498
I have a function that add nodes :
public void AddNode(Guid ID, string name, Guid parentNode)
{
MyNode node = new MyNode ();
node.ID = ID;
node.Name = name;
node.ParentNode = parentNode;
AddNode(node);
}
How can I do a function that finds the lowest nodes?
Upvotes: 2
Views: 575
Reputation: 1084
how to find child nodes at root node [TreeView]
Try this link for pointers and once you find a node with no children place it in a List/Dictionary/etc whatever you want to use.
Upvotes: 0
Reputation: 333
Without the code for the overloaded function AddNode(Node), we can only guess.
If you only store the link to the parent node, you can't go down in the tree because for that, you'd have to obtain the links to the children. You could make your tree doubly-linked by also storing a link to the child node, or you could just store a link to the child node. If you've done that, you can make a recursive breadth-first-search or a depth-first-search beginning from the root to find your desired node.
Upvotes: 1