Facebook
From Lousy Mosquito, 5 Years ago, written in Plain Text.
Embed
Download Paste or View Raw
Hits: 215
  1.  public void preorder(Wezel root)
  2.         {
  3.             Console.WriteLine(root.wartosc);
  4.             if (root.lewe != null)
  5.             {
  6.                 preorder(root.lewe);
  7.             }
  8.             if (root.prawe != null)
  9.             {
  10.                 preorder(root.prawe);
  11.             }
  12.         }
  13.         public void inorder(Wezel root)
  14.         {
  15.             if (root.lewe != null)
  16.             {
  17.                 inorder(root.lewe);
  18.             }
  19.             Console.WriteLine(root.wartosc);
  20.             if (root.prawe != null)
  21.             {
  22.                 inorder(root.prawe);
  23.             }
  24.         }
  25.         public void postorder(Wezel root)
  26.         {
  27.             if (root.lewe != null)
  28.             {
  29.                 postorder(root.lewe);
  30.             }
  31.             if (root.prawe != null)
  32.             {
  33.                 postorder(root.prawe);
  34.             }
  35.             Console.WriteLine(root.wartosc);
  36.         }
  37.         public void test()
  38.         {
  39.             if (length < 1)
  40.             {
  41.                 root = null;
  42.                 Console.WriteLine("Brak drzewa");
  43.             }
  44.             else
  45.             {
  46.                 preorder(root);
  47.             }
  48.         }
  49.         public void test2()
  50.         {
  51.             if (length < 1)
  52.             {
  53.                 root = null;
  54.                 Console.WriteLine("Brak drzewa");
  55.             }
  56.             else
  57.             {
  58.                 inorder(root);
  59.             }
  60.         }
  61.         public void test3()
  62.         {
  63.             if (length < 1)
  64.             {
  65.                 root = null;
  66.                 Console.WriteLine("Brak drzewa");
  67.             }
  68.             else
  69.             {
  70.                 postorder(root);
  71.             }
  72.         }