static void Main() { Drzewo drzewko = new Drzewo(1); Console.WriteLine($"glebokosc = {drzewko.glebokosc}"); drzewko.Push(2); Console.WriteLine($"glebokosc = {drzewko.glebokosc}"); drzewko.Push(3); Console.WriteLine($"glebokosc = {drzewko.glebokosc}"); drzewko.Push(4); Console.WriteLine($"glebokosc = {drzewko.glebokosc}"); drzewko.Push(5); Console.WriteLine($"glebokosc = {drzewko.glebokosc}"); drzewko.Push(6); Console.WriteLine($"glebokosc = {drzewko.glebokosc}"); drzewko.Push(7); Console.WriteLine($"glebokosc = {drzewko.glebokosc}"); Console.ReadLine(); }
static void Main(string[] args) { Console.WriteLine("Drzewo\n"); Drzewo drzewo = new Drzewo(); drzewo.root = new Node("F"); Node wB = new Node("B"); Node wA = new Node("A"); Node wC = new Node("C"); Node wD = new Node("D"); Node wE = new Node("E"); Node wG = new Node("G"); Node wH = new Node("H"); Node wI = new Node("I"); wD.AddChild(wC); wD.AddChild(wE); wB.AddChild(wA); wB.AddChild(wD); wI.AddChild(wH); wG.AddChild(wI); drzewo.root.AddChild(wB); drzewo.root.AddChild(wG); Console.WriteLine("Pre-order:"); drzewo.root.ShowPreOrder(); Console.WriteLine(); Console.WriteLine(); Console.WriteLine("Post-order:"); drzewo.root.ShowPostOreder(); Console.WriteLine(); Console.WriteLine(); Console.WriteLine("Wysokosc = {0}", drzewo.root.GetHeight()); Console.ReadKey(); }