Exemple #1
0
        public void InOrderTraversal()
        {
            if (LeftNode != null)
            {
                LeftNode.InOrderTraversal();
            }

            Console.Write($"{this.Data}, ");

            if (RightNode != null)
            {
                RightNode.InOrderTraversal();
            }
        }
Exemple #2
0
        static void Main(string[] args)
        {
            InitializeTree();

            Console.WriteLine("\n\nIn-order traversal: ");
            tree.InOrderTraversal();

            Console.WriteLine("\n\nPre-order traversal: ");
            tree.PreOrderTraversal();

            Console.WriteLine("\n\nPost-order traversal: ");
            tree.PostOrderTraversal();

            Console.Write($"\n\nTree contains {18}: {tree.Contains(18)}");

            var node = tree.FindRecursive(10);

            Console.Write($"\n\nFind node recursively: {node.Data} || Count: {node.Count}");

            Console.Write($"\n\nFind node non-recursively: {tree.Find(66).Data}");

            Console.ReadLine();
        }