示例#1
0
        public void PostOrderTraversal()
        {
            if (LeftNode != null)
            {
                LeftNode.PostOrderTraversal();
            }

            if (RightNode != null)
            {
                RightNode.PostOrderTraversal();
            }

            Console.Write($"{Data}, ");
        }
示例#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();
        }