TheCommunicator
asked on
How to implement Tree in C#
I am not sure what C library supports and what not. I searched online but did not find anything substantial. Can anybody suggest me a good article or guide me with a small code snipped which can help me implement a tree structure in C#?
Check this article: http://www.codeproject.com/KB/recipes/treecollection.aspx
ASKER
How about something like this?
public class node
{
public node ParentNode;
public int value;
public node(int Nodevalue)
{
this.value = Nodevalue;
}
public node(int Nodevalue, node CurrentParent)
{
this.value = Nodevalue;
this.ParentNode = CurrentParent;
}
public node lookupParent(node LookupNode)
{
return LookupNode.ParentNode;
}
}
]
ASKER
I mean I am just starting out from scratch and I am not sure what would be the optimum way to store the informaiton. should I also include the children's information?
IF I do then it would becode redundant information and there would be a lot of scope for conflict.
On the other hand if I do not include the children's information then I do not see a good way to traverse the whole tryy given the root node.
Please advise?
IF I do then it would becode redundant information and there would be a lot of scope for conflict.
On the other hand if I do not include the children's information then I do not see a good way to traverse the whole tryy given the root node.
Please advise?
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
ASKER
Ok Yes, you are right. Thanks.