Example #1
0
        public void InsertInOrder(T newNodeData)
        {
            var comparison = newNodeData.CompareTo(Data);

            if (comparison <= 0)
            {
                if (LeftNode == null)
                {
                    SetLeftChild(new TreeNode <T>(newNodeData));
                }
                else
                {
                    LeftNode.InsertInOrder(newNodeData);
                }
            }
            else
            {
                if (RightNode == null)
                {
                    SetRightChild(new TreeNode <T>(newNodeData));
                }
                else
                {
                    RightNode.InsertInOrder(newNodeData);
                }
            }
        }