Why does ICommonBinaryTreeNode have a TNode generic parameter?

Nov 25, 2012 at 5:12 PM
Edited Nov 25, 2012 at 5:13 PM

A relatively easier implementation of this interface could be 

 

public interface ICommonBinaryTreeNode<T>
    {
        ICommonBinaryTreeNode<T> Left { get; set; }

        ICommonBinaryTreeNode<T> Right { get; set; }

        TValue Value { get; set; }
    }

But, I understand the intention of the authors that the Left & Right children could a node of any other type. Can you cite an tree example that could take advantage of the generic parameter <Tnode> ?

Nov 25, 2012 at 6:15 PM

Also,  CommonBinaryTree<TNode,TValue> restricts the use of TNode to a ICommonBinaryTreeNode, i.e the node should ONLY have LEFT and RIGHT children. This also means that I cannot implement any generic  node say TOP,BOTTOM and hence I am still wondering the rationale behind TNode in  ICommonBinaryTreeNode<TNode,TValue>. Hope I am making some sense , please correct my understanding.