A node in a binary tree can only have left and right child nodes. This structure can go deeper. As an effort to strongly-type this kind of data, I came up with below implementation of generic interface and class.
public interface INode<T> { T LeftNode { get; set; } T RightNode { get; set; } string Path { get; set; } } public class Node: INode<Node> { public Node LeftNode { get; set; } public Node RightNode { get; set; } public string Path { get; set; } } Node class seems a little quirky because it passes its own type to INode.
Top comments (0)