Example #1
0
        static void Main(string[] args)
        {
            Node test = new Node(10);

            Console.WriteLine(test.Add(5));
            Console.WriteLine(test.Add(3));
            Console.WriteLine(test.Add(12));
            Console.WriteLine(test.Add(11));

            test.Print();

            Console.WriteLine(test.FindNode(5));
            Console.WriteLine(test.FindNode(10));

            Console.WriteLine("Count: " + test.Count());

            test.FindNode(12).Add(15);

            test.FindNode(15).num = 35;

            test.Print();

            Console.WriteLine("Count: " + test.Count());

            Console.WriteLine(test.Remove(12));

            test.Print();

            Console.WriteLine("Count: " + test.Count());
        }
Example #2
0
        public Node FindNode(int num)
        {
            if (num == this.num)
            {
                return(this);
            }

            if (LNode != null)
            {
                if (LNode.FindNode(num) != null)
                {
                    return(LNode.FindNode(num));
                }
            }
            if (RNode != null)
            {
                if (RNode.FindNode(num) != null)
                {
                    return(RNode.FindNode(num));
                }
            }

            return(null);
        }