static void Main(string[] args) { //BinarySearchTree tree = new BinarySearchTree(); //Random random = new Random(); //for (int i = 20; i < 30; i++) // tree.Add(random.Next(i) - 15); //tree.LoadToFile(); //tree.ReadFromFile(); //Console.WriteLine(tree.DFS() + "\n-------------------------------------------"); //tree.InOrderTraversal(); //Console.WriteLine(tree.DFS() + "\n-------------------------------------------"); //tree.PreOrderTraversal(); //Console.WriteLine(tree.DFS() + "\n-------------------------------------------"); //tree.PostOrderTraversal(); //Console.WriteLine(tree.DFS() + "\n-------------------------------------------"); //BinTree bin_tree = new BinTree("1(-2(8*) 1( 1 *) ) "); //ThreadedBinTree th_tree = new ThreadedBinTree(bin_tree); //th_tree.DFS(); //Console.WriteLine("-------------------------------------------"); //th_tree.Connections(); BinTree bin_tree = new BinTree("1(-2(* 8(* 0)) 1 ) "); Console.WriteLine("-------------------------------------------"); ThreadedBinTree th_tree = new ThreadedBinTree(bin_tree); th_tree.DFS(); Console.WriteLine("-------------------------------------------"); th_tree.Connections(); Console.WriteLine("-------------------------------------------"); }
public ThreadedBinTree(BinTree bin_tree) { if (bin_tree == null || bin_tree.Root == null) root = null; else { root = new ThreadedNode(bin_tree.Root); max = bin_tree.max; build(ref Root.left, bin_tree.Root.left); build(ref Root.right, bin_tree.Root.right); re_build(); } }
public void Test5() { bin_tree = new BinTree("1 ( -2 (2*)*)"); }
public void Test4() { bin_tree = new BinTree("1( -2 *)"); }
public void Test3() { bin_tree = new BinTree("1"); }
public void Test2() { bin_tree = new BinTree("*"); }
public void Test1() { bin_tree = new BinTree("1(-2(8*) 1( 1 *) ) "); }