private void btn_generate_Click(object sender, RoutedEventArgs e) { Random rnd = new Random(); int num; tb_array.Text = ""; tb_Sortedarray.Text = ""; num = rnd.Next(0, 100); tb_array.Text = tb_array.Text + num.ToString().PadLeft(3); tree MyTree = new tree(num); int n = int.Parse(txt_input.Text); for (int i = 1; i < n; i++) { num = rnd.Next(0, 100); tb_array.Text = tb_array.Text + num.ToString().PadLeft(3); MyTree.addRc(num); //using recursive function // MyTree.add(num); //none recursive function } string treestring = ""; MyTree.Print(null, ref treestring); tb_Sortedarray.Text = treestring; }
static void Main(string[] args) { tree tree = new tree(); Random random = new Random(); for (var i = 0; i < 35; i++) { tree.Add(random.Next(0, 100)); } while (true) { Console.Clear(); tree.Print(tree.Root); Console.WriteLine("-------------------------------------"); tree.InOrderTraversal(tree.Root); Console.WriteLine("Delete node: "); tree.Delete(Convert.ToInt32(Console.ReadLine())); } }