1. Implement the following C# method to write to a file all the values of the binary tree nodes at the specified depth from the root. Root has depth 0. Start from the leftmost node. An iterative solution is preferred over a recursive one.
class TreeNode
{
public int Value { get; set; }
public TreeNode LeftChild { get; set; }
public TreeNode RightChild { get; set; }
public TreeNode Parent { get; set; }
};
static void WriteTreeLevelT oFile(
string filename,
TreeNode root,
int depth);
2. When I enter this code into Visual Studio I get an error at, "Static Void".
3. I need to write the results out to a file.
This is my try at the solution:
using System;
using System.Collecti ons.Generic;
using System.Linq;
using System.Text;
using System.IO;
namespace MS_TreeDemo
{
class TreeNode
{
public int Value { get; set; }
public TreeNode LeftChild { get; set; }
public TreeNode RightChild { get; set; }
public TreeNode Parent { get; set; }
};
static void WriteTreeLevelT oFile(
string ("J:\MS_TreeDem o\TreeNode.txt" ),
TreeNode root,
int depth);
}
}
Thanks for your help.
class TreeNode
{
public int Value { get; set; }
public TreeNode LeftChild { get; set; }
public TreeNode RightChild { get; set; }
public TreeNode Parent { get; set; }
};
static void WriteTreeLevelT oFile(
string filename,
TreeNode root,
int depth);
2. When I enter this code into Visual Studio I get an error at, "Static Void".
3. I need to write the results out to a file.
This is my try at the solution:
using System;
using System.Collecti ons.Generic;
using System.Linq;
using System.Text;
using System.IO;
namespace MS_TreeDemo
{
class TreeNode
{
public int Value { get; set; }
public TreeNode LeftChild { get; set; }
public TreeNode RightChild { get; set; }
public TreeNode Parent { get; set; }
};
static void WriteTreeLevelT oFile(
string ("J:\MS_TreeDem o\TreeNode.txt" ),
TreeNode root,
int depth);
}
}
Thanks for your help.
Comment