Пример #1
0
        public void addnod(nod <T> n)
        {
            Type X = n.GetType();

            arb[nnod] = new nod <T>(n);
            nnod++;
        }
Пример #2
0
 public nod(nod <T> n)
 {
     val = n.val;
     par = n.par;
     fs  = n.fs;
     fd  = n.fd;
 }
Пример #3
0
        private void swap(nod <T> x, nod <T> y)
        {
            T a = x.val;

            x.val = y.val;
            y.val = a;
        }
Пример #4
0
 public void postoAfis(nod <T> r)      //SDR
 {
     if (r != null)
     {
         postoAfis(r.fs);
         postoAfis(r.fd);
         Console.Write(r.val + "  ");
     }
 }
Пример #5
0
 public void inoAfis(nod <T> r)        //SRD
 {
     if (r != null)
     {
         inoAfis(r.fs);
         Console.Write(r.val + "  ");
         inoAfis(r.fd);
     }
 }
Пример #6
0
 public void preoAfis(nod <T> r)       //RSD
 {
     if (r != null)
     {
         Console.Write(r.val + "  ");
         preoAfis(r.fs);
         preoAfis(r.fd);
     }
 }
Пример #7
0
 public nod(T v, nod <T> p)
 {
     val = v;
     par = p;
     if (p.fs != null && p.fd != null)
     {
         Console.WriteLine("ERR:ta deja are 2 copchii !!");
     }
     else
     if (p.fs == null)
     {
         p.fs = this;
     }
     else
     {
         p.fd = this;
     }
 }
Пример #8
0
 public void addnod(T x)
 {
     arb[nnod] = new nod <T>(x);
     if (nnod != 0)
     {
         if (nnod % 2 == 0)
         {
             arb[nnod].par          = arb[(nnod - 2) / 2];
             arb[(nnod - 2) / 2].fd = arb[nnod];
         }
         else
         {
             arb[nnod].par          = arb[(nnod - 1) / 2];
             arb[(nnod - 1) / 2].fs = arb[nnod];
         }
     }
     nnod++;
 }