コード例 #1
0
        static void Main(string[] args)
        {
            BinaryTree tree = new BinaryTree();

            tree.root            = new Node(1);
            tree.root.left       = new Node(2);
            tree.root.right      = new Node(3);
            tree.root.left.left  = new Node(4);
            tree.root.left.right = new Node(5);


            TreeTraversal treeTraversal = new TreeTraversal();

            treeTraversal.FindLeastCommonAncestor(tree.root, 5, 4);
            treeTraversal.InOrderIterative(tree.root);
            treeTraversal.InOrderRecursive(tree.root);
        }