コード例 #1
0
 public void Uygula(nod <turistik> rr, List <otel> a)
 {
     if (rr == null)
     {
     }
     else
     {
         foreach (otel i in rr.data.oteller)
         {
             a.Add(i);
         }
         Uygula(rr.left, a);
         Uygula(rr.right, a);
     }
 }
コード例 #2
0
 private nod <T> search(T ara, nod <T> bak)      //arama metodu -RECURSİVE -PRİVATE'TİR KULLANILMAZ
 {
     if (bak == null)
     {
         return(null);
     }
     else if (ara.Equals(bak.data))
     {
         return(bak);
     }
     else
     {
         return(ata(search(ara, bak.left), search(ara, bak.right)));
     }
 }
コード例 #3
0
 private nod <T> ata(nod <T> a, nod <T> b)     //Search metodunun yardımcı metodu
 {
     if (a == null && b != null)
     {
         return(b);
     }
     else if (a != null && b == null)
     {
         return(a);
     }
     else if (a != null && b != null)
     {
         return(a);
     }
     else
     {
         return(null);
     }
 }
コード例 #4
0
        private void add(nod <T> yeni)       //add metodu -PRİVATE'TİR KULLANILMAZ
        {
            nod <T> c = root;

            if (root == null)
            {
                root = yeni;
            }
            else
            {
                while (c != null)
                {
                    if (c.data.CompareTo(yeni.data) == -1)
                    {
                        if (c.right == null)
                        {
                            c.right     = yeni;
                            yeni.parent = c;
                            c           = null;
                        }
                        else
                        {
                            c = c.right;
                        }
                    }
                    else
                    {
                        if (c.left == null)
                        {
                            c.left      = yeni;
                            yeni.parent = c;
                            c           = null;
                        }
                        else
                        {
                            c = c.left;
                        }
                    }
                }
            }
        }
コード例 #5
0
        public void Add(T yeni)        //Kullanılabilir add metodu
        {
            nod <T> tt = new nod <T>(yeni);

            this.add(tt);
        }
コード例 #6
0
 public bintree()
 {
     root = null;
 }
コード例 #7
0
 private T remove(nod <T> e)       //Ağaçtan eleman silmek için kullanılan metod -PRİVATE'TİR KULLANILMAZ
 {
     if (e == root)
     {
         nod <T> temp = root;
         if (root.right == null && root.left == null)
         {
             root = null;
             return(temp.data);
         }
         else if (root.right == null && root.left != null)
         {
             root = root.left;
             return(temp.data);
         }
         else if (e.right != null && e.left == null)
         {
             root = root.right;
             return(temp.data);
         }
         else
         {
             nod <T> g = root.left;
             while (g.right != null)
             {
                 g = g.right;
             }
             T temper = root.data;
             e.data = g.data;
             g.data = temper;
             return(remove(g));
         }
     }
     else if (e.right == null && e.left == null)
     {
         if (e.parent.right == e)
         {
             nod <T> temp = e.parent.right;
             e.parent.right = null;
             return(temp.data);
         }
         else
         {
             nod <T> temp = e.parent.left;
             e.parent.left = null;
             return(temp.data);
         }
     }
     else if (e.right == null && e.left != null)
     {
         if (e.parent.right == e)
         {
             nod <T> temp = e.parent.right;
             e.parent.right = e.left;
             return(temp.data);
         }
         else
         {
             nod <T> temp = e.parent.left;
             e.parent.left = e.left;
             return(temp.data);
         }
     }
     else if (e.right != null && e.left == null)
     {
         if (e.parent.right == e)
         {
             nod <T> temp = e.parent.right;
             e.parent.right = e.right;
             return(temp.data);
         }
         else
         {
             nod <T> temp = e.parent.left;
             e.parent.left = e.right;
             return(temp.data);
         }
     }
     else
     {
         nod <T> g = e.right;
         while (g.left != null)
         {
             g = g.left;
         }
         T temp = e.data;
         e.data = g.data;
         g.data = temp;
         return(remove(g));
     }
 }