private void PreOrderInt(altKategoriDugum dugum)
 {
     if (dugum == null)
     {
         return;
     }
     Ziyaret(dugum);
     PreOrderInt(dugum.sol);
     PreOrderInt(dugum.sag);
 }
 private void InOrderInt(altKategoriDugum dugum)
 {
     if (dugum == null)
     {
         return;
     }
     InOrderInt(dugum.sol);
     Ziyaret(dugum);
     InOrderInt(dugum.sag);
 }
        public altKategoriDugum MaksDeger()
        {
            altKategoriDugum tempSag = kok;

            while (tempSag.sag != null)
            {
                tempSag = tempSag.sag;
            }
            return(tempSag);
        }
        public altKategoriDugum MinDeger()
        {
            altKategoriDugum tempSol = kok;

            while (tempSol.sol != null)
            {
                tempSol = tempSol.sol;
            }
            return(tempSol);
        }
        public int DugumSayisi(altKategoriDugum dugum)
        {
            int count = 0;

            if (dugum != null)
            {
                count  = 1;
                count += DugumSayisi(dugum.sol);
                count += DugumSayisi(dugum.sag);
            }
            return(count);
        }
 private altKategoriDugum AraInt(altKategoriDugum dugum,
                                 int anahtar)
 {
     //if (dugum == null)
     //    return null;
     //else if ((int)dugum.veri == anahtar)
     //    return dugum;
     //else if ((int)dugum.veri > anahtar)
     //    return (AraInt(dugum.sol, anahtar));
     //else
     //    return (AraInt(dugum.sag, anahtar));
     return(null);
 }
        public int YaprakSayisi(altKategoriDugum dugum)
        {
            int count = 0;

            if (dugum != null)
            {
                if ((dugum.sol == null) && (dugum.sag == null))
                {
                    count = 1;
                }
                else
                {
                    count = count + YaprakSayisi(dugum.sol) + YaprakSayisi(dugum.sag);
                }
            }
            return(count);
        }
예제 #8
0
        static void Main(string[] args)
        {
            urun pc1 = new urun();

            pc1.satisFiyat = 100;
            urun pc2 = new urun();

            pc2.satisFiyat = 90;
            urun pc3 = new urun();

            pc3.satisFiyat = 120;
            urun pc4 = new urun();

            pc4.satisFiyat = 130;
            urun pc5 = new urun();

            pc5.satisFiyat = 10;
            urun pc6 = new urun();

            pc6.satisFiyat = 400;
            urunHeapDugum pc1Heap = new urunHeapDugum(pc1);
            urunHeapDugum pc2Heap = new urunHeapDugum(pc2);
            urunHeapDugum pc3Heap = new urunHeapDugum(pc3);
            urunHeapDugum pc4Heap = new urunHeapDugum(pc4);
            urunHeapDugum pc5Heap = new urunHeapDugum(pc5);
            urunHeapDugum pc6Heap = new urunHeapDugum(pc6);
            urunHeap      uHeap   = new urunHeap(6);

            uHeap.Insert(pc1);
            uHeap.Insert(pc2);
            uHeap.Insert(pc3);
            uHeap.Insert(pc4);
            uHeap.Insert(pc5);
            uHeap.Insert(pc6);
            uHeap.DisplayHeap();
            altKategoriDugum altk = new altKategoriDugum("asda");

            altk.urunEkle(pc1);
            altKategoriIkiliAramaAgac arama = new altKategoriIkiliAramaAgac(altk);

            Console.WriteLine(arama.DugumleriYazdir());
            Console.ReadKey();
        }
        private altKategoriDugum Successor(altKategoriDugum silDugum)
        {
            altKategoriDugum successorParent = silDugum;
            altKategoriDugum successor       = silDugum;
            altKategoriDugum current         = silDugum.sag;

            while (current != null)
            {
                successorParent = successor;
                successor       = current;
                current         = current.sol;
            }
            if (successor != silDugum.sag)
            {
                successorParent.sol = successor.sag;
                successor.sag       = silDugum.sag;
            }
            return(successor);
        }
        public void Ekle(string deger, String kategoriAd)
        {
            //Yeni eklenecek düğümün parent'ı
            // compare metodu gelecek !!!!!!!!!!!!!
            altKategoriDugum tempParent = new altKategoriDugum();
            //Kökten başla ve ilerle
            altKategoriDugum tempSearch = kok;

            while (tempSearch != null)
            {
                tempParent = tempSearch;
                //Deger zaten var, çık.
                if (string.Compare(deger, tempSearch.kategoriIsim) == 0)
                {
                    return;
                }
                else if (string.Compare(deger, tempSearch.kategoriIsim) == -1)
                {
                    tempSearch = tempSearch.sol;
                }
                else if (string.Compare(deger, tempSearch.kategoriIsim) == 1)
                {
                    tempSearch = tempSearch.sag;
                }
            }
            altKategoriDugum eklenecek = new altKategoriDugum(deger);

            //Ağaç boş, köke ekle
            if (kok == null)
            {
                kok = eklenecek;
            }
            else if (string.Compare(deger, tempSearch.kategoriIsim) == -1)
            {
                tempParent.sol = eklenecek;
            }
            else if (string.Compare(deger, tempSearch.kategoriIsim) == 1)
            {
                tempParent.sag = eklenecek;
            }
        }
예제 #11
0
 public altKategoriDugum(string isim)
 {
     kategoriIsim = isim;
     sol          = null;
     sag          = null;
 }
 public altKategoriIkiliAramaAgac(altKategoriDugum kok)
 {
     this.kok = kok;
 }
 private void Ziyaret(altKategoriDugum dugum)
 {
     dugumler += dugum.kategoriIsim + " ";
 }