public void AddNodes()
        {
            Console.Write("\nEnter comma Separated node elements:");
            var binaryTreeString   = Console.ReadLine();
            var binaryTreeElements = binaryTreeString.Split(',');

            foreach (var item in binaryTreeElements)
            {
                this.Root = AddNode(this.Root, int.Parse(item));
                this.Count++;
            }
        }
 public ThreadedNode FindSuccessor(ThreadedNode temp)
 {
     if (temp.IsRightThreaded)
     {
         return(temp.Right);
     }
     else
     {
         temp = temp.Right;
         while (temp.IsLeftThreaded == false)
         {
             temp = temp.Left;
         }
         return(temp);
     }
 }
        private static ThreadedNode AddNode(ThreadedNode root, int value)
        {
            if (root == null)
            {
                return(new ThreadedNode(value));
            }

            if (root.Value >= value)     //is part of left subtree
            {
                if (root.IsLeftThreaded) //reached to the far left end
                {
                    var temp = new ThreadedNode(value);

                    temp.Left  = root.Left;
                    temp.Right = root;

                    root.Left           = temp;
                    root.IsLeftThreaded = false;
                }
                else //need to go further left
                {
                    root.Left = AddNode(root.Left, value);
                }
            }
            else //is part of right subtree
            {
                if (root.IsRightThreaded) //reached to the far right end
                {
                    var temp = new ThreadedNode(value);
                    temp.Left  = root;
                    temp.Right = root.Right;

                    root.Right           = temp;
                    root.IsRightThreaded = false;
                }
                else //need to go further left
                {
                    root.Right = AddNode(root.Right, value);
                }
            }
            return(root);
        }