public void TreeTraversalsM() { TreeTraversals treeTraversals = new TreeTraversals(); NodeChar root = new NodeChar('A') { left = new NodeChar('B'), right = new NodeChar('C') }; root.left.left = new NodeChar('D') { //left = new Node('F'), //right = new Node('G') }; root.left.right = new NodeChar('E') { //left = new Node('H'), //right = new Node('I') }; treeTraversals.PreOrderTreeTraversal(root); Console.WriteLine(); treeTraversals.InOrderTreeTraversal(root); Console.WriteLine(); treeTraversals.PostOrderTreeTraversal(root); Console.WriteLine(); }
public void BSTFromPreorderTraversalM() { int[] preOrderTraversal = { 10, 5, 1, 7, 40, 50 }; BSTFromPreorderTraversalC bstFromPreorderTraversal = new BSTFromPreorderTraversalC(); NodeInt root = bstFromPreorderTraversal.ConstructBSTFromPreorderTraversal(preOrderTraversal, preOrderTraversal.Length); TreeTraversals treeTraversals = new TreeTraversals(); treeTraversals.PreOrderTreeTraversal(root); }
public void ConstructTreeFromTraversalsM() { char[] preOrderTraversal = { 'A', 'B', 'D', 'C' }; char[] inOrderTraversal = { 'D', 'B', 'A', 'C' }; //char[] postOrderTraversal = { 'D', 'E', 'B', 'C', 'A' }; ConstructTreeFromTraversal constructTreeFromTraversal = new ConstructTreeFromTraversal(); NodeChar root = constructTreeFromTraversal.BuildTree(inOrderTraversal, preOrderTraversal, 0, inOrderTraversal.Length - 1); TreeTraversals treeTraversals = new TreeTraversals(); treeTraversals.PostOrderTreeTraversal(root); }